Skip to content

Instantly share code, notes, and snippets.

@joncotton
Created May 29, 2012 21:46
Show Gist options
  • Select an option

  • Save joncotton/2830986 to your computer and use it in GitHub Desktop.

Select an option

Save joncotton/2830986 to your computer and use it in GitHub Desktop.
Add Microsoft Clippy to any webpage
/**
* A bookmarklet to Clippify any webpage.
*
* All possible by: http://www.smore.com/clippy-js
*/
javascript:(function(){function c(a,b){console.log("dynamically loading-",a);if(a.readyState){a.onreadystatechange=function(){if(a.readyState=="loaded"||a.readyState=="complete"){a.onreadystatechange=null;if(b){b()}}}}else{a.onload=function(){if(b){b()}}}}function d(){console.log("launching clippy");clippy.load("Clippy",function(a){$(".clippy").css("position","fixed");$(".clippy").css("z-index",1e3);a.show();a.moveTo(100,100)})}function e(){b=document.createElement("script");b.src="https://raw.github.com/smore-inc/clippy.js/master/build/clippy.js";document.body.appendChild(b);var a=document.createElement("link");a.rel="stylesheet";a.type="text/css";a.media="all";a.href="https://raw.github.com/smore-inc/clippy.js/master/build/clippy.css";document.getElementsByTagName("head")[0].appendChild(a)}var a;var b;if(typeof jQuery=="undefined"||jQuery.fn.jquery<"1.7"){a=document.createElement("script");var f=/^https:/i.test(document.location)?"https":"http";a.src=f+"://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";document.body.appendChild(a);c(a,function(){e();c(b,d)})}else{if(typeof clippy=="undefined"){e();c(b,d)}else{d()}}})()
@joncotton
Copy link
Author

Tested in Firefox, Chrome, Safari. Doesn't work in IE because the onload/onreadystatechange handler isn't working. This script will take control of $ so it'll stomp all over Prototype.js. By "tested" I mean it worked when I tried it and I didn't try all that hard. It's for fun not profit. Mileage may vary.

The next improvement I'd make is to provide a control panel of sorts to let you initiate all the action animations.

@VitorLuizC
Copy link

That's fucking awesome! lol

@paperluigis
Copy link

VM42:1 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/smore-inc/clippy.js/master/build/clippy.css with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.

yeah. now you have to run github-pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment