Last active
April 30, 2018 17:20
-
-
Save cuylerstuwe/eaea07d476eddd426e54cd01bf58ab3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Icon for Panda Crazy | |
| // @namespace salembeats | |
| // @version 1.1 | |
| // @description . | |
| // @author Cuyler Stuwe (salembeats) | |
| // @include http*://worker.mturk.com/?filters[search_term]=pandacrazy=on* | |
| // @include http*://worker.mturk.com/requesters/PandaCrazy/projects* | |
| // @include http*://worker.mturk.com/?PandaCrazy* | |
| // @include http*://worker.mturk.com/?end_signin=1&filters%5Bsearch_term%5D=pandacrazy%3Don* | |
| // @require https://raw.githubusercontent.com/salembeats/favico.js/master/favico.js | |
| // @icon https://i.imgur.com/snRSm80.gif | |
| // @grant GM_xmlhttpRequest | |
| // ==/UserScript== | |
| // TODO: Future -- Set favicon with the favicon link, then use Favico to manipulate badges. | |
| const globals = { | |
| settings: { | |
| PANDA_CRAZY_ICON: { | |
| URL: "https://orig00.deviantart.net/ca84/f/2018/017/d/0/f2u_panda_icon_by_nawnii-dc0c4bu.png", | |
| EMBED_ID: "newPcLogoEmbed" | |
| }, | |
| } | |
| }; | |
| async function main() { | |
| document.body.insertAdjacentHTML("beforeend", `<img id="${globals.settings.PANDA_CRAZY_ICON.EMBED_ID}" style="display: none;">`); | |
| GM_xmlhttpRequest({ | |
| url: globals.settings.PANDA_CRAZY_ICON.URL, | |
| method: "GET", | |
| responseType: "blob", | |
| onload: (response) => { | |
| loadFavicon(response); | |
| } | |
| }); | |
| } | |
| function loadFavicon(response) { | |
| let imageUrl = URL.createObjectURL(response.response); | |
| let favico = new Favico({ | |
| animation: "pop" // For badges... later. | |
| }); | |
| document.getElementById(globals.settings.PANDA_CRAZY_ICON.EMBED_ID).src = imageUrl; | |
| favico.image(document.getElementById(globals.settings.PANDA_CRAZY_ICON.EMBED_ID)); | |
| } | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment