Skip to content

Instantly share code, notes, and snippets.

@fuzzyfox
Created April 3, 2014 13:42
Show Gist options
  • Save fuzzyfox/9954583 to your computer and use it in GitHub Desktop.
Save fuzzyfox/9954583 to your computer and use it in GitHub Desktop.
Bookmarklet: Super Goggles

Super Goggles

Takes Webmakers X-Ray Goggles and adds a little spice so that you can goggle on published Thimble projects.

Install

Compress the JS in supergoggles.js and add to your bookmarks toolbar. Then use in place of X-Ray Goggles.

My personal favourite tool to do this easily is http://userjs.up.seesaa.net/js/bookmarklet.html. Simply copy the code in supergoggles.js and paste it into the tool. Name the bookmarklet and drag the link at the bottom of the page to your bookmarks toolbar. Done.

(function(window, document, undefined){
function injectGoggles(doc) {
var doc = doc || window.document;
var script = doc.createElement('script');
var lang = navigator.userLanguage || navigator.language || 'en-US';
script.src = 'https://goggles.webmaker.org/en-US/webxray.js';
script.className = 'webxray';
script.setAttribute('data-lang', lang);
script.setAttribute('data-baseuri', 'https://goggles.webmaker.org/' + lang);
doc.body.appendChild(script);
}
var url = document.createElement('a');
url.href = window.location.href;
if(url.host.match(/makes\.org/) && url.pathname.match(/^\/thimble\//) && url.pathname.substr(url.pathname.length - 1) !== '_'){
var frame = document.querySelector('iframe.embed-iframe').contentWindow;
injectGoggles(frame.document);
}
else {
injectGoggles();
}
})(this, this.document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment