Forked from peterhost/microdata-tool-bookmarklet-pretty.js
Last active
April 9, 2024 17:09
-
-
Save 06b/70b9f2b8c210d4948cf612fc47e8ce02 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("https://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://raw.githubusercontent.com/06b/microdata-tool/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://raw.githubusercontent.com/06b/microdata-tool/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("https://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://raw.githubusercontent.com/06b/microdata-tool/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://raw.githubusercontent.com/06b/microdata-tool/master/schemas.js",function(){return typeof $.microdata=="undefined"?msg="Sorry, but schema.js wasn't able to load":msg="schema.js loaded "})})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment