Last active
August 29, 2015 14:15
-
-
Save cray0000/010d5d743a40eb935252 to your computer and use it in GitHub Desktop.
Use http://mrcoles.com/bookmarklet/ to create a bookmarklet
This file contains hidden or 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 () { | |
| var el = document.createElement('pre'), | |
| b = document.getElementsByTagName('body')[0], | |
| otherjQuery = false, | |
| msg = '', | |
| libs = [ | |
| function loadjQuery() { | |
| if (typeof jQuery != 'undefined') { | |
| showMsg('This page already using jQuery v' + jQuery.fn.jquery); | |
| } else { | |
| if (typeof $ == 'function') { | |
| otherjQuery = true; | |
| } | |
| getScript('//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js', function () { | |
| if (typeof jQuery == 'undefined') { | |
| showMsg('Sorry, but jQuery wasn\'t able to load') | |
| } else { | |
| showMsg('This page is now jQuerified with v' + jQuery.fn.jquery + otherjQuery ? ' and noConflict(). Use $jq(), not $().' : ''); | |
| } | |
| }); | |
| } | |
| }, | |
| function loadLodash() { | |
| if (typeof _ != 'undefined') { | |
| showMsg('This page already using lodash v' + _.VERSION); | |
| } | |
| getScript('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.min.js', function () { | |
| showMsg('This page is now has lodash'); | |
| }); | |
| } | |
| ]; | |
| el.style.position = 'fixed'; | |
| el.style.top = '0'; | |
| el.style.padding = '5px 10px'; | |
| el.style.zIndex = 9001; | |
| el.style.fontSize = '12px'; | |
| el.style.color = '#222'; | |
| el.style.backgroundColor = '#f99'; | |
| function getScript(url, success) { | |
| var script = document.createElement('script'); | |
| script.src = url; | |
| var head = document.getElementsByTagName('head')[0], | |
| done = false; | |
| script.onload = script.onreadystatechange = function () { | |
| if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { | |
| done = true; | |
| success(); | |
| script.onload = script.onreadystatechange = null; | |
| head.removeChild(script); | |
| } | |
| }; | |
| head.appendChild(script); | |
| } | |
| function showMsg(msg) { | |
| if (!document.body.contains(el)) { | |
| b.appendChild(el); | |
| } | |
| el.appendChild(document.createTextNode(msg + '\n')); | |
| window.setTimeout(function () { | |
| if (typeof jQuery == 'undefined') { | |
| b.removeChild(el); | |
| } else { | |
| jQuery(el).fadeOut('slow', function () { | |
| jQuery(this).remove(); | |
| }); | |
| if (otherjQuery) { | |
| $jq = jQuery.noConflict(); | |
| } | |
| } | |
| }, 2500); | |
| } | |
| libs.forEach(function (init) { | |
| init(); | |
| }) | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment