Skip to content

Instantly share code, notes, and snippets.

@fuzzyfox
Created April 3, 2014 13:42
Show Gist options
  • Select an option

  • Save fuzzyfox/9954583 to your computer and use it in GitHub Desktop.

Select an option

Save fuzzyfox/9954583 to your computer and use it in GitHub Desktop.

Revisions

  1. William Duyck created this gist Apr 3, 2014.
    7 changes: 7 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # Super Goggles
    Takes Webmakers [X-Ray Goggles](https://goggles.webmaker.org/) and adds a little spice so that you can goggle on published [Thimble](https://thimble.webmaker.org) 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.
    23 changes: 23 additions & 0 deletions supergoggles.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    (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);