Last active
July 9, 2020 06:13
-
-
Save rostegg/9f5558aa61614178264fae217d86546f to your computer and use it in GitHub Desktop.
Tiny webextension to navigate through random "prnt.sc" screenshots. Idk who might need it, purely for research purposes
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
// Load extension with manifest, and click on the icon that appears on browser panel | |
// And don't forget to load random pic to extension folder and name it "icon.png" | |
// | |
const endpoint = "https://prnt.sc" | |
browser.browserAction.onClicked.addListener(() => { | |
const rndId = (length) => { | |
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789' | |
const charactersLength = characters.length | |
const getRndChar = function() { | |
return characters.charAt(Math.floor(Math.random() * charactersLength)) | |
} | |
return Array. | |
from(Array(length), value => getRndChar()). | |
join('') | |
} | |
const id = rndId(6) | |
browser.tabs.update({url: `${endpoint}/${id}`}) | |
}); |
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
{ | |
"manifest_version": 2, | |
"name": "Open random prnt.sc url", | |
"version": "1.0", | |
"permissions": [ | |
"tabs", | |
"activeTab", | |
"webRequest", | |
"webNavigation" | |
], | |
"browser_action": { | |
"default_icon": "icon.png", | |
"default_title": "Random prnt.sc url" | |
}, | |
"background": { | |
"scripts": ["background.js"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment