Skip to content

Instantly share code, notes, and snippets.

@rostegg
Last active July 9, 2020 06:13
Show Gist options
  • Save rostegg/9f5558aa61614178264fae217d86546f to your computer and use it in GitHub Desktop.
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
// 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}`})
});
{
"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