
Open links quietly di martin
Open links in muted tabs from the right-click context menu. Also with "Quiet Mode".
Devi utilizzare Firefox per poter installare questa estensione
Metadati estensione
Screenshot


Informazioni sull’estensione
This extension allows you to open links, bookmarks and bookmark folders in muted tabs, from the right-click context menu.
It adds a button on the tab bar that turns on/off the "Quiet Mode".
When Quiet Mode is ON all new tabs are automatically muted.
This add-on needs the permission to read your bookmarks. If you're worried about that, just read the source code. It will take you less than a minute.
BACKGROUND.JS
let quietMode = false;
function onCreatedItem() {
if (browser.runtime.lastError) {
console.log(`Error: ${browser.runtime.lastError}`);
}
}
function onError(error) {
console.log(`Error: ${error}`);
}
function onCreatedTab(tab) {
browser.tabs.update(tab.id, {muted: true});
}
function createTab(tabUrl) {
var creating = browser.tabs.create({
url:tabUrl,
active:false
});
creating.then(onCreatedTab, onError);
}
function getFolderChildren(bookmarkId) {
var gettingChildren = browser.bookmarks.getChildren(bookmarkId);
gettingChildren.then(onFulfilledFolder, onError);
}
function onFulfilledFolder(children) {
for (child of children) {
if (child.url){
createTab(child.url);
} else {
getFolderChildren(child.id);
}
}
}
function onFulfilled(bookmarks) {
if (bookmarks[0].url) {
createTab(bookmarks[0].url)
} else {
getFolderChildren(bookmarks[0].id);
}
}
function handleCreated(tab) {
if (quietMode) {
onCreatedTab(tab);
}
}
function toggleQuietMode(isEnabled){
if (!isEnabled) {
browser.browserAction.setTitle({title: "Back to normal"});
browser.browserAction.setIcon({path: "tab-audio-muted.svg"});
quietMode = true;
} else {
browser.browserAction.setTitle({title: null});
browser.browserAction.setIcon({path: null})
quietMode = false;
}
}
browser.menus.create({
id: "open-link-muted",
title: "Open link quietly",
contexts: ["link"]
}, onCreatedItem);
browser.menus.create({
id: "open-bookmark-muted",
title: "Open quietly",
contexts: ["bookmark"]
}, onCreatedItem);
browser.menus.onClicked.addListener((info, tab) => {
switch (info.menuItemId) {
case "open-link-muted":
createTab(info.linkUrl);
break;
case "open-bookmark-muted":
var gettingBookmarks = browser.bookmarks.get(info.bookmarkId);
gettingBookmarks.then(onFulfilled, onError);
break;
}
});
browser.browserAction.onClicked.addListener(() => {
toggleQuietMode(quietMode);
});
browser.tabs.onCreated.addListener((tab) => {
if (quietMode) {
handleCreated(tab);
}
});
MANIFEST.JSON
{
"manifest_version": 2,
"name":"Open link quietly",
"description":"Open links in muted tabs from the right-click context menu. Also with \"quiet mode\".",
"version":"0",
"developer": {
"name": "martin"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"menus",
"bookmarks"
],
"browser_action": {
"browser_style": true,
"default_icon": "tab-audio-playing.svg",
"default_title": "Open links/tabs quietly",
"default_area": "tabstrip"
}
}
It adds a button on the tab bar that turns on/off the "Quiet Mode".
When Quiet Mode is ON all new tabs are automatically muted.
This add-on needs the permission to read your bookmarks. If you're worried about that, just read the source code. It will take you less than a minute.
BACKGROUND.JS
let quietMode = false;
function onCreatedItem() {
if (browser.runtime.lastError) {
console.log(`Error: ${browser.runtime.lastError}`);
}
}
function onError(error) {
console.log(`Error: ${error}`);
}
function onCreatedTab(tab) {
browser.tabs.update(tab.id, {muted: true});
}
function createTab(tabUrl) {
var creating = browser.tabs.create({
url:tabUrl,
active:false
});
creating.then(onCreatedTab, onError);
}
function getFolderChildren(bookmarkId) {
var gettingChildren = browser.bookmarks.getChildren(bookmarkId);
gettingChildren.then(onFulfilledFolder, onError);
}
function onFulfilledFolder(children) {
for (child of children) {
if (child.url){
createTab(child.url);
} else {
getFolderChildren(child.id);
}
}
}
function onFulfilled(bookmarks) {
if (bookmarks[0].url) {
createTab(bookmarks[0].url)
} else {
getFolderChildren(bookmarks[0].id);
}
}
function handleCreated(tab) {
if (quietMode) {
onCreatedTab(tab);
}
}
function toggleQuietMode(isEnabled){
if (!isEnabled) {
browser.browserAction.setTitle({title: "Back to normal"});
browser.browserAction.setIcon({path: "tab-audio-muted.svg"});
quietMode = true;
} else {
browser.browserAction.setTitle({title: null});
browser.browserAction.setIcon({path: null})
quietMode = false;
}
}
browser.menus.create({
id: "open-link-muted",
title: "Open link quietly",
contexts: ["link"]
}, onCreatedItem);
browser.menus.create({
id: "open-bookmark-muted",
title: "Open quietly",
contexts: ["bookmark"]
}, onCreatedItem);
browser.menus.onClicked.addListener((info, tab) => {
switch (info.menuItemId) {
case "open-link-muted":
createTab(info.linkUrl);
break;
case "open-bookmark-muted":
var gettingBookmarks = browser.bookmarks.get(info.bookmarkId);
gettingBookmarks.then(onFulfilled, onError);
break;
}
});
browser.browserAction.onClicked.addListener(() => {
toggleQuietMode(quietMode);
});
browser.tabs.onCreated.addListener((tab) => {
if (quietMode) {
handleCreated(tab);
}
});
MANIFEST.JSON
{
"manifest_version": 2,
"name":"Open link quietly",
"description":"Open links in muted tabs from the right-click context menu. Also with \"quiet mode\".",
"version":"0",
"developer": {
"name": "martin"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"menus",
"bookmarks"
],
"browser_action": {
"browser_style": true,
"default_icon": "tab-audio-playing.svg",
"default_title": "Open links/tabs quietly",
"default_area": "tabstrip"
}
}
Valuta la tua esperienza utente
PermessiUlteriori informazioni
Questo componente aggiuntivo necessita di:
- Leggere e modificare i segnalibri
Ulteriori informazioni
- Versione
- 1
- Dimensione
- 9,83 kB
- Ultimo aggiornamento
- 4 anni fa (3 lug 2021)
- Categorie correlate
- Licenza
- Solo GNU General Public License v3.0
- Cronologia versioni
Aggiungi alla raccolta
Altre estensioni di martin
- Non ci sono ancora valutazioni
- Non ci sono ancora valutazioni
- Non ci sono ancora valutazioni
- Non ci sono ancora valutazioni
- Non ci sono ancora valutazioni
- Non ci sono ancora valutazioni