preparing to make Manifest v2 versions as alternatives because of how fucked the rollout of v3 is

This commit is contained in:
2024-10-20 18:07:21 -06:00
parent 3fcdc86679
commit e950136ad2
5 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
// Cross-platform namespace support
window.browser = (function () {
return window.browser ||
window.msBrowser ||
window.chrome;
})();
var shuffle = function (array) {
var currentIndex = array.length;
var temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
};
browser.action.onClicked.addListener(function() {
browser.tabs.query({}, function(tabs) {
let count = Math.floor(tabs.length / 2) + 1 // I don't remember why we need an extra +1 here, but it is necessary
var ok = confirm("Are you sure you want to close " + count + " tabs?")
if (ok) {
shuffle(tabs)
tabs = tabs.slice(1, count)
let tab_identifiers = [];
for (tab in tabs) {
tab_identifiers.push(tabs[tab].id)
}
browser.tabs.remove(ids)
}
})
})
function updateCount() {
browser.tabs.query({}, function(tabs) {
let count = Math.floor(tabs.length / 2)
browser.action.setBadgeText({ text: "" + count })
})
}
browser.tabs.onCreated.addListener(updateCount)
browser.tabs.onRemoved.addListener(updateCount)
browser.windows.onCreated.addListener(updateCount)
browser.windows.onRemoved.addListener(updateCount)
updateCount()

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,34 @@
{
"manifest_version": 3,
"name": "The Snap",
"description": "Too many tabs open? Halve your workload.",
"version": "1.1.3",
"icons": {
"16": "images/gauntlet16.png",
"48": "images/gauntlet48.png",
"128": "images/gauntlet128.png"
},
"author": "rose@tangentfox.com",
"homepage_url": "https://blog.tangentfox.com/the-snap-browser-extension/",
"developer": {
"name": "Rose (Tangent) Liverman",
"url": "https://blog.tangentfox.com/the-snap-browser-extension/"
},
"action": {},
"permissions": [
"tabs"
],
"background": {
"service_worker": "background.js",
"scripts": [ "background.js" ],
"persistent": false
},
"browser_specific_settings": {
"gecko": {
"id": "{7b9819b6-6bd3-4cb8-a5b3-9ae6eb2e75ea}"
},
"gecko_android": {
"id": "{7b9819b6-6bd3-4cb8-a5b3-9ae6eb2e75e0}"
}
}
}