Repository: mbostock/bl.ocks.org Branch: master Commit: 0526df138b4e Files: 12 Total size: 7.4 KB Directory structure: gitextract_h59rf4u7/ ├── .gitignore ├── LICENSE ├── README.md ├── chrome/ │ ├── bl.ocks.chrome/ │ │ ├── blocks.js │ │ └── manifest.json │ └── bl.ocks.chrome.crx └── firefox/ ├── bl.ocks.firefox.xpi ├── build.sh ├── chrome.manifest ├── content/ │ ├── blocks.js │ └── blocks.xul └── install.rdf ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.pyc heroku/secret.js ================================================ FILE: LICENSE ================================================ Copyright (c) 2010, Michael Bostock All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The name Michael Bostock may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: README.md ================================================ # bl.ocks.org Browser Extensions is a simple Gist viewer for HTML/JavaScript examples. To install the **Chrome** extension, visit the [Chrome Web Store](https://chrome.google.com/webstore/detail/blocksorg/phjkbonaifennbfpmieeipknnkhaoiaf) and click *Add to Chrome*. To install the **Firefox** extension, visit the [Mozilla Add-ons](https://addons.mozilla.org/en-US/firefox/addon/blocksorg/). Then click *Add to Firefox*. A **Safari** extension is no longer supported because Apple requires a $99 per year fee to obtain a developer certificate. Please don’t use Safari. ================================================ FILE: chrome/bl.ocks.chrome/blocks.js ================================================ var observer = new MutationObserver(redraw); observer.observe(document.documentElement, {childList: true, subtree: true}); redraw(); function redraw() { var container = document.querySelector(".file-navigation-options"); if (!container) return; var parts = location.pathname.substring(1).split("/"), user = parts[0], id = parts[1], sha = parts[2]; if (!user || user.length > 39 || !/^[a-z0-9](?:-?[a-z0-9])*$/i.test(user)) return; if (!/^([0-9]+|[0-9a-f]{20,})$/.test(id)) id = null; if (!/^[0-9a-f]{40}$/.test(sha)) sha = null; var anchor = container.querySelector(".bl-ocks-button"), href = "http://bl.ocks.org/" + user + (id ? "/" + id + (sha ? "/" + sha : "") : ""); if (!anchor) { var div = document.createElement("div"); div.className = "file-navigation-option"; anchor = div.appendChild(document.createElement("a")); anchor.className = "btn btn-sm bl-ocks-button"; var svg = anchor.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); svg.setAttribute("class", "octicon octicon-link-external"); svg.setAttribute("height", 16); svg.setAttribute("width", 12); var path = svg.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "path")); path.setAttribute("d", "M11 10h1v3c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V3c0-0.55 0.45-1 1-1h3v1H1v10h10V10zM6 2l2.25 2.25-3.25 3.25 1.5 1.5 3.25-3.25 2.25 2.25V2H6z"); anchor.appendChild(document.createTextNode(" bl.ocks")); // Disconnect to avoid observing our own mutations. observer.disconnect(); container.appendChild(div); observer.observe(document.documentElement, {childList: true, subtree: true}); } if (anchor.href !== href) { anchor.href = href; } } ================================================ FILE: chrome/bl.ocks.chrome/manifest.json ================================================ { "manifest_version": 2, "name": "bl.ocks.org", "version": "1.3.10", "short_name": "bl.ocks", "description": "View any gist on bl.ocks.org.", "icons": {"128": "icon-128.png"}, "content_scripts": [ { "matches": ["https://gist.github.com/*"], "js": ["blocks.js"], "run_at": "document_end" } ] } ================================================ FILE: firefox/build.sh ================================================ #/bin/bash rm -f bl.ocks.firefox.xpi zip bl.ocks.firefox.xpi chrome.manifest content/blocks.js content/blocks.xul install.rdf ================================================ FILE: firefox/chrome.manifest ================================================ content bl.ocks.org content/ content bl.ocks.org content/ contentaccessible=yes overlay chrome://browser/content/browser.xul chrome://bl.ocks.org/content/blocks.xul ================================================ FILE: firefox/content/blocks.js ================================================ window.addEventListener("load", function load() { window.removeEventListener("load", load, false); gBrowser.addEventListener("DOMContentLoaded", function(e) { var document = e.originalTarget; if (document.location.hostname !== "gist.github.com") return; var observer = new MutationObserver(redraw); observer.observe(document.documentElement, {childList: true, subtree: true}); redraw(); function redraw() { var container = document.querySelector(".file-navigation-options"); if (!container) return; var parts = document.location.pathname.substring(1).split("/"), user = parts[0], id = parts[1], sha = parts[2]; if (!user || user.length > 39 || !/^[a-z0-9](?:-?[a-z0-9])*$/i.test(user)) return; if (!/^([0-9]+|[0-9a-f]{20,})$/.test(id)) id = null; if (!/^[0-9a-f]{40}$/.test(sha)) sha = null; var anchor = container.querySelector(".bl-ocks-button"), href = "http://bl.ocks.org/" + user + (id ? "/" + id + (sha ? "/" + sha : "") : ""); if (!anchor) { var div = document.createElement("div"); div.className = "file-navigation-option"; anchor = div.appendChild(document.createElement("a")); anchor.className = "btn btn-sm bl-ocks-button"; var svg = anchor.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); svg.setAttribute("class", "octicon octicon-link-external"); svg.setAttribute("height", 16); svg.setAttribute("width", 12); var path = svg.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "path")); path.setAttribute("d", "M11 10h1v3c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V3c0-0.55 0.45-1 1-1h3v1H1v10h10V10zM6 2l2.25 2.25-3.25 3.25 1.5 1.5 3.25-3.25 2.25 2.25V2H6z"); anchor.appendChild(document.createTextNode(" bl.ocks")); // Disconnect to avoid observing our own mutations. observer.disconnect(); container.appendChild(div); observer.observe(document.documentElement, {childList: true, subtree: true}); } if (anchor.href !== href) { anchor.href = href; } } }, false); }, false); ================================================ FILE: firefox/content/blocks.xul ================================================