diff options
author | Christian Segundo | 2023-11-17 16:22:08 +0100 |
---|---|---|
committer | Christian Segundo | 2023-11-17 16:22:08 +0100 |
commit | 7dbeeca952b31f7c01dc20c48c184f075de44c85 (patch) | |
tree | 110bab8f0d7d042a8b1f0cee6c733d3164f025d4 /background.js | |
download | moz-tab-rename-master.tar.gz |
Diffstat (limited to 'background.js')
-rw-r--r-- | background.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/background.js b/background.js new file mode 100644 index 0000000..2b0b984 --- /dev/null +++ b/background.js @@ -0,0 +1,21 @@ +browser.menus.create({ + id: "tab-rename", + title: "Rename", + contexts: ["tab"], +}, function() { + if (browser.runtime.lastError) { + console.log(`Error: ${browser.runtime.lastError}`); + } +}); + +let tabRename = ` + var newTitle = window.prompt("", document.title); + if (newTitle) { document.title = newTitle; } +`; + +browser.menus.onClicked.addListener((info, tab) => { + if (info.menuItemId == "tab-rename") { + browser.tabs.update(tab.id, { active: true }); + browser.tabs.executeScript(tab.id, { code: tabRename }); + } +}); |