Skip to content

Commit

Permalink
NEXT-81 Create userscript for Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
kscc25 committed Apr 3, 2016
1 parent 3055f1f commit 9d2caae
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ NEXT - Agar.io Extension
## Download

- For Google Chrome: http://snsa.github.io/NEXT/next.chrome.user.js
- For Mozilla Firefox: http://snsa.github.io/NEXT/next.firefox.user.js

## Usage
- Install [Tampermonkey](https://tampermonkey.net/) extension for Google Chrome
- Install the userscript
or [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) for Firefox
- Install the corresponding userscript you downloaded above for each browser
- Go to http://agar.io

## Run in development
Expand Down
1 change: 1 addition & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cd build

sed -i "s/localhost:8080/snsa.github.io\/NEXT/g" index.html
cp ../userscripts/next.chrome.user.js .
cp ../userscripts/next.firefox.user.js .

git init
git config user.name "SNSA Bot"
Expand Down
43 changes: 43 additions & 0 deletions userscripts/next.firefox.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ==UserScript==
// @name NEXT
// @description The next generation of Agar.io extension
// @version 0.0.1
// @author NEXT
// @match http://agar.io/*
// @match https://agar.io/*
// @downloadURL http://snsa.github.io/NEXT/next.firefox.user.js
// @updateURL http://snsa.github.io/NEXT/next.firefox.user.js
// @grant none
// ==/UserScript==

function opengradingwindow(htmlContent) {
var element = document.createElement('script');
var target = document.getElementsByTagName('head')[0] || (document.body || document.documentElement);
element.type = 'text/javascript';
element.textContent = '(function(html){var d=window.document;d.open();d.write(html);d.close();})(' + JSON.stringify(htmlContent) + ');';
target.appendChild(element);
};

function replacePage(url) {
if (!window.PIXI) {
var req = new XMLHttpRequest;
req.onreadystatechange = function() {
if (4 == req.readyState) {
if (200 == req.status) {
document.documentElement.innerHTML = '<h1>Loading...<h1>';
opengradingwindow(req.responseText);
}
}
};
req.open('GET', url, true);
req.send();
}
}
var sites = {
'/': 'http://snsa.github.io/NEXT/',
'/dev': 'http://localhost:8080/'
};
var pathname = location.pathname;
if (sites.hasOwnProperty(pathname)) {
replacePage(sites[pathname]);
};

0 comments on commit 9d2caae

Please sign in to comment.