Created
November 27, 2011 12:59
-
-
Save peterhost/1397528 to your computer and use it in GitHub Desktop.
Quick and Dirty Bookmarklet for the excellent https://github.com/KrofDrakula/microdata-tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modified from code of "JQuerify" bookmarklet | |
// http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet | |
(function() { | |
function z(a, b) { | |
var c = document.createElement("script"); | |
c.src = a; | |
var d = document.getElementsByTagName("head")[0], e = !1; | |
c.onload = c.onreadystatechange = function() { | |
!e && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") && (e = !0, b(), c.onload = c.onreadystatechange = null, d.removeChild(c)); | |
}; | |
d.appendChild(c); | |
} | |
function d() { | |
a.innerHTML = msg, b.appendChild(a), window.setTimeout(function() { | |
typeof jQuery == "undefined" ? b.removeChild(a) : (jQuery(a).fadeOut("slow", function() { | |
jQuery(this).remove(); | |
}), otherlib && ($jq = jQuery.noConflict())); | |
}, 2500); | |
} | |
var a = document.createElement("div"), b = document.getElementsByTagName("body")[0]; | |
otherlib = !1, msg = "", a.style.position = "fixed", a.style.height = "32px", a.style.width = "220px", a.style.marginLeft = "-110px", a.style.top = "0", a.style.left = "50%", a.style.padding = "5px 10px", a.style.zIndex = 1001, a.style.fontSize = "12px", a.style.color = "#222", a.style.backgroundColor = "#f99"; | |
//load jquery (if not already loaded) | |
if (typeof jQuery != "undefined") { | |
msg = "This page already using jQuery v" + jQuery.fn.jquery + "... proceeding", d(); | |
} else { | |
typeof $ == "function" && (otherlib = !0), z("http://code.jquery.com/jquery-latest.min.js", function() { | |
return typeof jQuery == "undefined" ? msg = "Sorry, but jQuery wasn't able to load" : (msg = "This page is now jQuerified with v" + jQuery.fn.jquery, otherlib && (msg += " and noConflict(). Use $jq(), not $().")), d(); | |
}); | |
} | |
//load jquery.microdata.js | |
typeof $ == "function" && (otherlib = !0), z("https://github.com/KrofDrakula/microdata-tool/raw/master/jquery.microdata.js", function() { | |
return typeof $.microdata == "undefined" ? msg = "Sorry, but jquery.microdata.js wasn't able to load" : (msg = "jquery.microdata.js loaded " ); | |
}); | |
//load schema.js | |
typeof $ == "function" && (otherlib = !0), z("https://github.com/KrofDrakula/microdata-tool/raw/master/schemas.js", function() { | |
// didn't find what to test schema.js against | |
return typeof $.microdata == "undefined" ? msg = "Sorry, but schema.js wasn't able to load" : (msg = "schema.js loaded " ); | |
}); | |
})(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (function(){function a(a,b){var c=document.createElement("script");c.src=a;var d=document.getElementsByTagName("head")[0],e=!1;c.onload=c.onreadystatechange=function(){!e&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")&&(e=!0,b(),c.onload=c.onreadystatechange=null,d.removeChild(c))},d.appendChild(c)}function b(){c.innerHTML=msg,d.appendChild(c),window.setTimeout(function(){typeof jQuery=="undefined"?d.removeChild(c):(jQuery(c).fadeOut("slow",function(){jQuery(this).remove()}),otherlib&&($jq=jQuery.noConflict()))},2500)}var c=document.createElement("div"),d=document.getElementsByTagName("body")[0];otherlib=!1,msg="",c.style.position="fixed",c.style.height="32px",c.style.width="220px",c.style.marginLeft="-110px",c.style.top="0",c.style.left="50%",c.style.padding="5px 10px",c.style.zIndex=1001,c.style.fontSize="12px",c.style.color="#222",c.style.backgroundColor="#f99",typeof jQuery!="undefined"?(msg="This page already using jQuery v"+jQuery.fn.jquery+"... proceeding",b()):(typeof $=="function"&&(otherlib=!0),a("http://code.jquery.com/jquery-latest.min.js",function(){return typeof jQuery=="undefined"?msg="Sorry, but jQuery wasn't able to load":(msg="This page is now jQuerified with v"+jQuery.fn.jquery,otherlib&&(msg+=" and noConflict(). Use $jq(), not $().")),b()})),typeof $=="function"&&(otherlib=!0),a("https://github.com/KrofDrakula/microdata-tool/raw/master/jquery.microdata.js",function(){return typeof $.microdata=="undefined"?msg="Sorry, but jquery.microdata.js wasn't able to load":msg="jquery.microdata.js loaded "}),typeof $=="function"&&(otherlib=!0),a("https://github.com/KrofDrakula/microdata-tool/raw/master/schemas.js",function(){return typeof $.microdata=="undefined"?msg="Sorry, but schema.js wasn't able to load":msg="schema.js loaded "})})(); |
Hi! on some sites there is only alert about JQuery is loaded, but no microdata widget, and on another sites even no JQuery loaded alert - just nothing...:( on some https sites after clicking onto bookmarklet i get an alert, FF blocked unsecure content. Have you ever seen such misbehavior?
I try this code but this is not working
This currently does not work on Firefox due to incorrect MIME types (text/plain
) of the URLs served by github.com/KrofDrakula/microdata-tool/raw/...
:
La ressource à l’adresse « https://raw.githubusercontent.com/KrofDrakula/microdata-tool/master/jquery.microdata.js » a été bloquée en raison d’un type MIME (« text/plain ») incorrect (X-Content-Type-Options: nosniff).
Échec du chargement pour l’élément <script> dont la source est « https://github.com/KrofDrakula/microdata-tool/raw/master/jquery.microdata.js ». blog:1:1
La ressource à l’adresse « https://raw.githubusercontent.com/KrofDrakula/microdata-tool/master/schemas.js » a été bloquée en raison d’un type MIME (« text/plain ») incorrect (X-Content-Type-Options: nosniff).
Échec du chargement pour l’élément <script> dont la source est « https://github.com/KrofDrakula/microdata-tool/raw/master/schemas.js ».
(errors are in French)
Using those URLs instead fixed the issue:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jsfiddle so that you can drag it directly to your bookmarks:
http://jsfiddle.net/peterhost/ZJfpL/14/embedded/result/