-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patheditCustomButtonInTab.html
More file actions
35 lines (33 loc) · 18.2 KB
/
Copy patheditCustomButtonInTab.html
File metadata and controls
35 lines (33 loc) · 18.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE HTML>
<meta charset="utf-8"/>
<title>Edit Custom Button in Tab [0.1.9 - 2019-08-16]</title>
<body>
<a href="custombutton://%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0D%0A%3Ccustombutton%20xmlns%3Acb%3D%22http%3A//xsms.nm.ru/custombuttons/%22%3E%0A%20%20%3Cname%3EEdit%20Custom%20Button%20in%20Tab%3C/name%3E%0A%20%20%3Cimage%3E%3C%21%5BCDATA%5Bdata%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAitJREFUeNrEk0tIVVEUhr99zrnHc1+SkYQVFWo20G6SgkFRDorEILFJDoogkoLoXfOopEZCYIFlIITlRIUiC5UmFZVk1igwCAozfD9uat17z97tc5XK0pGDFiz289/rXz//FkopFhMGiwyr5GoHHgkpZUnCde9LqXwwHyuR3HVNIzZpGrubbLtjfHwYyzvywIYpHp0o386ajAAD3/R1MRfugZeFoGcgbm9pedo+7VVVCMvTwKt8tGwrfXGb5mfRJFj8VV0Ki7hpk9t5gW35lYx9GcSZGFOGSjJQvuXpYd4PTLPUYU6m+Q1SgzbBkEPey0tUHjlJfU8j0c8j+Aa/ahFn2x2cdknVgLBfpx5DyTQIBGx8+oHjras4vX8DtfWNFG0q4gmPyas9VqgZqEbNAEvPUnW1sCMI+QVBPXc02Ar5ONiURW55NsHus1TkjNDW2srHdYcormo/Z2kG+0p35BPTfaaHrVnBBAmt75QwKK3LYuPetdDbDxMTdHc2ELn4gfWj32l+MFQhdla1KVdKpCvxBPXAcWUSlQEaYgeIlK2GvmENHuHOmxVcW3mLoDuqn09gGjNiF8xnEPWw+DUFpTA0BS+uc/tdDodrnhf+445dV9p/LaQw+SH8nBfVRBMpKi0zm5LIEupq7lF541Vhy6lIV3XGTRw5qdWXM078bRSBK3zs6b3MWxEgplxSPnWS2e8kwXfPbO4SanIefy4cf7bWtdAl8d9/408BBgBVmNFVzOyEfgAAAABJRU5ErkJggg%3D%3D%5D%5D%3E%3C/image%3E%0A%20%20%3Cmode%3E0%3C/mode%3E%0A%20%20%3Cinitcode%3E%3C%21%5BCDATA%5B//%20http%3A//infocatcher.ucoz.net/js/cb/editCustomButtonInTab.js%0A//%20https%3A//github.com/Infocatcher/Custom_Buttons/tree/master/Edit_Custom_Button_in_Tab%0A%0A//%20Edit%20Custom%20Button%20in%20Tab%20button%20for%20Custom%20Buttons%0A//%20%28code%20for%20%22initialization%22%20section%29%0A%0A//%20%28c%29%20Infocatcher%202012-2014%2C%202017-2019%0A//%20version%200.1.9%20-%202019-08-16%0A%0A//%20Note%3A%0A//%20In%20Firefox%203.6%20and%20older%3A%0A//%20-%20Force%20enables%20%22Save%20size%20and%20position%20of%20editor%20windows%20separately%20for%20each%20custom%20button%22%0A//%20%20%20option%20for%20editor%20in%20tab%20%28because%20doesn%27t%20work%20without%20this%29%0A//%20-%20tab%20with%20editor%20can%27t%20be%20closed%20sometimes%20using%20OK/Cancel%20buttons%0A%0Avar%20editInTabLabel%20%3D%20%28function%28%29%20%7B%0A%09var%20locale%20%3D%20%28function%28%29%20%7B%0A%09%09if%28%22Services%22%20in%20window%20%26%26%20%22locale%22%20in%20Services%29%20%7B%0A%09%09%09var%20locales%20%3D%20Services.locale.requestedLocales%20//%20Firefox%2064+%0A%09%09%09%09%7C%7C%20Services.locale.getRequestedLocales%20%26%26%20Services.locale.getRequestedLocales%28%29%3B%0A%09%09%09if%28locales%29%0A%09%09%09%09return%20locales%5B0%5D%3B%0A%09%09%7D%0A%09%09var%20prefs%20%3D%20%22Services%22%20in%20window%20%26%26%20Services.prefs%0A%09%09%09%7C%7C%20Components.classes%5B%22@mozilla.org/preferences-service%3B1%22%5D%0A%09%09%09%09.getService%28Components.interfaces.nsIPrefBranch%29%3B%0A%09%09function%20pref%28name%2C%20type%29%20%7B%0A%09%09%09return%20prefs.getPrefType%28name%29%20%21%3D%20prefs.PREF_INVALID%20%3F%20prefs%5B%22get%22%20+%20type%20+%20%22Pref%22%5D%28name%29%20%3A%20undefined%3B%0A%09%09%7D%0A%09%09if%28%21pref%28%22intl.locale.matchOS%22%2C%20%22Bool%22%29%29%20%7B%20//%20Also%20see%20https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid%3D1414390%0A%09%09%09var%20locale%20%3D%20pref%28%22general.useragent.locale%22%2C%20%22Char%22%29%3B%0A%09%09%09if%28locale%20%26%26%20locale.substr%280%2C%209%29%20%21%3D%20%22chrome%3A//%22%29%0A%09%09%09%09return%20locale%3B%0A%09%09%7D%0A%09%09return%20Components.classes%5B%22@mozilla.org/chrome/chrome-registry%3B1%22%5D%0A%09%09%09.getService%28Components.interfaces.nsIXULChromeRegistry%29%0A%09%09%09.getSelectedLocale%28%22global%22%29%3B%0A%09%7D%29%28%29.match%28/%5E%5Ba-z%5D*/%29%5B0%5D%3B%0A%09if%28locale%20%3D%3D%20%22ru%22%29%0A%09%09return%20%22%u0420%u0435%u0434%u0430%u043A%u0442%u0438%u0440%u043E%u0432%u0430%u0442%u044C%20%u0432%u043E%20%u0432%u043A%u043B%u0430%u0434%u043A%u0435%u2026%22%3B%0A%09return%20%22Edit%20button%20in%20tab%u2026%22%3B%0A%7D%29%28%29%3B%0A%0Aconst%20editorBaseUri%20%3D%20%22chrome%3A//custombuttons/content/editor.xul%22%3B%0Aconst%20cbIdTabAttr%20%3D%20%22custombuttons-editInTab-id%22%3B%0A%0Aconst%20editId%20%3D%20%22custombuttons-contextpopup-edit%22%3B%0Aconst%20editInTabId%20%3D%20editId%20+%20%22InTab%22%3B%0Avar%20editInTab%20%3D%20document.getElementById%28editInTabId%29%3B%0Aif%28editInTab%29%0A%09editInTab.parentNode.removeChild%28editInTab%29%3B%0Avar%20editItem%20%3D%20document.getElementById%28editId%29%3B%0AeditInTab%20%3D%20editItem.cloneNode%28true%29%3B%0AeditInTab.id%20%3D%20editInTabId%3B%0AeditInTab.setAttribute%28%22cb_id%22%2C%20editInTabId%29%3B%0AeditInTab.setAttribute%28%22label%22%2C%20editInTabLabel%29%3B%0AeditInTab.setAttribute%28%22oncommand%22%2C%20%22editCustomButtonInTab%28%29%3B%22%29%3B%0Aif%28%21Object.create%29%20//%20Firefox%203.6%20and%20older%0A%09editInTab.removeAttribute%28%22observes%22%29%3B%0AeditInTab.setAttribute%28%22image%22%2C%20%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAitJREFUeNrEk0tIVVEUhr99zrnHc1+SkYQVFWo20G6SgkFRDorEILFJDoogkoLoXfOopEZCYIFlIITlRIUiC5UmFZVk1igwCAozfD9uat17z97tc5XK0pGDFiz289/rXz//FkopFhMGiwyr5GoHHgkpZUnCde9LqXwwHyuR3HVNIzZpGrubbLtjfHwYyzvywIYpHp0o386ajAAD3/R1MRfugZeFoGcgbm9pedo+7VVVCMvTwKt8tGwrfXGb5mfRJFj8VV0Ki7hpk9t5gW35lYx9GcSZGFOGSjJQvuXpYd4PTLPUYU6m+Q1SgzbBkEPey0tUHjlJfU8j0c8j+Aa/ahFn2x2cdknVgLBfpx5DyTQIBGx8+oHjras4vX8DtfWNFG0q4gmPyas9VqgZqEbNAEvPUnW1sCMI+QVBPXc02Ar5ONiURW55NsHus1TkjNDW2srHdYcormo/Z2kG+0p35BPTfaaHrVnBBAmt75QwKK3LYuPetdDbDxMTdHc2ELn4gfWj32l+MFQhdla1KVdKpCvxBPXAcWUSlQEaYgeIlK2GvmENHuHOmxVcW3mLoDuqn09gGjNiF8xnEPWw+DUFpTA0BS+uc/tdDodrnhf+445dV9p/LaQw+SH8nBfVRBMpKi0zm5LIEupq7lF541Vhy6lIV3XGTRw5qdWXM078bRSBK3zs6b3MWxEgplxSPnWS2e8kwXfPbO4SanIefy4cf7bWtdAl8d9/408BBgBVmNFVzOyEfgAAAABJRU5ErkJggg%3D%3D%22%29%3B%0AeditItem.parentNode.insertBefore%28editInTab%2C%20editItem.nextSibling%29%3B%0A%0AArray.prototype.filter.call%28%20//%20Process%20already%20cloned%20menu%20items%0A%09document.getElementsByAttribute%28%22observes%22%2C%20editItem.getAttribute%28%22observes%22%29%29%2C%0A%09function%28mi%29%20%7B%0A%09%09var%20id%20%3D%20mi.id%20%7C%7C%20%22%22%3B%0A%09%09return%20mi%20%21%3D%20editItem%0A%09%09%09%26%26%20id.substr%280%2C%20editId.length%29%20%3D%3D%20editId%0A%09%09%09%26%26%20id.substr%280%2C%20editInTabId.length%29%20%21%3D%20editInTabId%3B%0A%09%7D%0A%29.forEach%28function%28editItem%2C%20i%29%20%7B%0A%09var%20clone%20%3D%20editInTab.cloneNode%28true%29%3B%0A%09clone.id%20+%3D%20%22-cloned-%22%20+%20i%3B%0A%09editItem.parentNode.insertBefore%28clone%2C%20editItem.nextSibling%29%3B%0A%7D%29%3B%0A%0A//%20Process%20%23custombuttons-contextpopup-sub%0Aconst%20editIdSub%20%3D%20editId%20+%20%22-sub%22%3B%0Avar%20editItemSub%20%3D%20document.getElementById%28editIdSub%29%3B%0Aif%28editItemSub%29%20%7B%0A%09var%20clone%20%3D%20editInTab.cloneNode%28true%29%3B%0A%09if%28editItemSub.hasAttribute%28%22observes%22%29%29%0A%09%09clone.setAttribute%28%22observes%22%2C%20editItemSub.getAttribute%28%22observes%22%29%29%3B%0A%09else%0A%09%09clone.removeAttribute%28%22observes%22%29%3B%0A%09clone.id%20+%3D%20%22-sub%22%3B%0A%09editItemSub.parentNode.insertBefore%28clone%2C%20editItemSub.nextSibling%29%3B%0A%7D%0A%0Awindow.editCustomButtonInTab%20%3D%20function%28btn%2C%20newTab%29%20%7B%20//%20Should%20be%20global%20to%20work%20in%20cloned%20menus%0A%09if%28%21btn%29%0A%09%09btn%20%3D%20custombuttons.popupNode%3B%0A%09if%28%21btn%29%0A%09%09return%3B%0A%09var%20btnId%20%3D%20btn.id%3B%0A%09var%20link%20%3D%20custombuttons.makeButtonLink%28%22edit%22%2C%20btnId%29%3B%0A%09var%20cbService%20%3D%20%22cbICustomButtonsService%22%20in%20Components.interfaces%0A%09%09%3F%20Components.classes%5B%22@xsms.nm.ru/custombuttons/cbservice%3B1%22%5D%0A%09%09%09.getService%28Components.interfaces.cbICustomButtonsService%29%0A%09%09%3A%20Components.classes%5B%22@xsms.nm.ru/custombuttons/cbservice%3B1%22%5D%20//%20Custom%20Buttons%200.0.5.9+%0A%09%09%09.getService%28Components.interfaces.nsISupports%29%0A%09%09%09.wrappedJSObject%3B%0A%09var%20param%20%3D%20cbService.getButtonParameters%28link%29%3B%0A%09var%20editorUriFull%20%3D%20editorBaseUri%0A%09%09+%20%22%3Fwindow%3D%22%20+%20cbService.getWindowId%28document.documentURI%29%0A%09%09+%20%22%26id%3D%22%20+%20btnId%3B%0A%09var%20editorUri%20%3D%20cbService.mode%20%26%2064%20/*CB_MODE_SAVE_EDITOR_SIZE_SEPARATELY*/%0A%09%09%7C%7C%20%21Object.create%20//%20Firefox%203.6%20and%20older%0A%09%09%3F%20editorUriFull%0A%09%09%3A%20editorBaseUri%3B%0A%0A%09//%20Search%20for%20already%20opened%20tab%0A%09var%20rawParam%20%3D%20unwrap%28param%29%3B%0A%09var%20isSeaMonkey%20%3D%20%22Services%22%20in%20window%20%26%26%20Services.appinfo.name%20%3D%3D%20%22SeaMonkey%22%3B%0A%09var%20ws%20%3D%20Components.classes%5B%22@mozilla.org/appshell/window-mediator%3B1%22%5D%0A%09%09.getService%28Components.interfaces.nsIWindowMediator%29%0A%09%09.getEnumerator%28isSeaMonkey%20%3F%20null%20%3A%20%22navigator%3Abrowser%22%29%3B%0A%09while%28ws.hasMoreElements%28%29%29%20%7B%0A%09%09let%20win%20%3D%20ws.getNext%28%29%3B%0A%09%09if%28isSeaMonkey%20%26%26%20win.location.href%20%21%3D%20%22chrome%3A//navigator/content/navigator.xul%22%29%0A%09%09%09continue%3B%0A%09%09let%20gBrowser%20%3D%20win.gBrowser%3B%0A%09%09let%20tabs%20%3D%20gBrowser.tabs%20%7C%7C%20gBrowser.tabContainer.childNodes%3B%0A%09%09for%28let%20i%20%3D%200%2C%20l%20%3D%20tabs.length%3B%20i%20%3C%20l%3B%20++i%29%20%7B%0A%09%09%09let%20tab%20%3D%20tabs%5Bi%5D%3B%0A%09%09%09if%28tab%20%3D%3D%20newTab%29%0A%09%09%09%09continue%3B%0A%09%09%09let%20browser%20%3D%20tab.linkedBrowser%3B%0A%09%09%09if%28%21browser%29%0A%09%09%09%09continue%3B%0A%09%09%09let%20loc%20%3D%20browser.currentURI.spec%3B%0A%09%09%09if%28loc.substr%280%2C%20editorBaseUriLength%29%20%21%3D%20editorBaseUri%29%0A%09%09%09%09continue%3B%0A%09%09%09let%20isSameEditor%20%3D%20loc%20%3D%3D%20editorUriFull%0A%09%09%09%09%7C%7C%20tab.getAttribute%28cbIdTabAttr%29%20%3D%3D%20btnId%3B%0A%09%09%09let%20win%20%3D%20browser.contentWindow%3B%20//%20Will%20be%20null%20for%20unloaded%20tab%0A%09%09%09if%28%21isSameEditor%20%26%26%20win%29%20%7B%0A%09%09%09%09let%20rawWin%20%3D%20unwrap%28win%29%3B%0A%09%09%09%09let%20winParam%20%3D%20%22arguments%22%20in%20rawWin%20%26%26%20rawWin.arguments.length%0A%09%09%09%09%09%3F%20unwrap%28rawWin.arguments%5B0%5D%29%0A%09%09%09%09%09%3A%20rawWin.editor%20%26%26%20rawWin.editor.param%3B%0A%09%09%09%09isSameEditor%20%3D%20winParam%20%26%26%20winParam.buttonLink%20%3D%3D%20link%3B%0A%09%09%09%7D%0A%09%09%09if%28isSameEditor%29%20%7B%0A%09%09%09%09gBrowser.selectedTab%20%3D%20tab%3B%0A%09%09%09%09win%20%26%26%20win.focus%28%29%3B%0A%09%09%09%09newTab%20%26%26%20setTimeout%28function%28%29%20%7B%0A%09%09%09%09%09gBrowser.removeTab%28newTab%29%3B%0A%09%09%09%09%7D%2C%200%29%3B%0A%09%09%09%09return%3B%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09//%20Or%20open%20new%20tab%0A%09var%20tab%20%3D%20newTab%3B%0A%09if%28%21tab%29%20%7B%0A%09%09tab%20%3D%20gBrowser.selectedTab%20%3D%20gBrowser.addTab%28editorUri%2C%20%7B%0A%09%09%09triggeringPrincipal%3A%20%22Services%22%20in%20window%20//%20Firefox%2063+%0A%09%09%09%09%26%26%20Services.scriptSecurityManager%0A%09%09%09%09%26%26%20Services.scriptSecurityManager.getSystemPrincipal%28%29%0A%09%09%7D%29%3B%0A%09%09initSessionStore%28%29%3B%0A%09%09tab.setAttribute%28cbIdTabAttr%2C%20btn.id%29%3B%0A%09%7D%0A%0A%09var%20browser%20%3D%20tab.linkedBrowser%3B%0A%09browser.addEventListener%28%22DOMContentLoaded%22%2C%20function%20load%28e%29%20%7B%0A%09%09var%20doc%20%3D%20e.target%3B%0A%09%09if%28doc.location%20%21%3D%20editorUri%29%0A%09%09%09return%3B%0A%09%09browser.removeEventListener%28e.type%2C%20load%2C%20false%29%3B%0A%0A%09%09var%20win%20%3D%20doc.defaultView%3B%0A%09%09win.arguments%20%3D%20%5Bparam%5D%3B%0A%0A%09%09var%20iconLink%20%3D%20doc.createElementNS%28%22http%3A//www.w3.org/1999/xhtml%22%2C%20%22link%22%29%3B%0A%09%09iconLink.rel%20%3D%20%22shortcut%20icon%22%3B%0A%09%09//iconLink.href%20%3D%20%22chrome%3A//custombuttons-context/content/icons/default/custombuttonsEditor.ico%22%3B%0A%09%09iconLink.href%20%3D%20getStdImage%28rawParam.image%29%3B%0A%09%09iconLink.style.display%20%3D%20%22none%22%3B%0A%09%09doc.documentElement.insertBefore%28iconLink%2C%20doc.documentElement.firstChild%29%3B%0A%0A%09%09var%20alreadyAsked%20%3D%20false%3B%0A%09%09function%20checkUnsaved%28e%29%20%7B%0A%09%09%09if%28alreadyAsked%29%0A%09%09%09%09return%3B%0A%09%09%09var%20dlg%20%3D%20unwrap%28doc%29.documentElement%3B%0A%09%09%09if%28%0A%09%09%09%09%22_fireButtonEvent%22%20in%20dlg%0A%09%09%09%09%09%3F%20%21dlg._fireButtonEvent%28%22cancel%22%29%0A%09%09%09%09%09%3A%20%21dlg.cancelDialog%28%29%0A%09%09%09%29%0A%09%09%09%09e.preventDefault%28%29%3B%0A%09%09%7D%0A%09%09function%20onDialogCancel%28e%29%20%7B%0A%09%09%09alreadyAsked%20%3D%20true%3B%0A%09%09%09//%20win.setTimeout%20shouldn%27t%20fire%20while%20confirmation%20dialog%20from%20the%20same%20window%20are%20opened%0A%09%09%09win.setTimeout%28function%28%29%20%7B%0A%09%09%09%09alreadyAsked%20%3D%20false%3B%0A%09%09%09%7D%2C%20100%29%3B%0A%09%09%7D%0A%09%09function%20destroy%28e%29%20%7B%0A%09%09%09win.removeEventListener%28%22dialogcancel%22%2C%20onDialogCancel%2C%20false%29%3B%0A%09%09%09win.removeEventListener%28%22beforeunload%22%2C%20checkUnsaved%2C%20false%29%3B%0A%09%09%09win.removeEventListener%28%22unload%22%2C%20destroy%2C%20false%29%3B%0A%09%09%7D%0A%09%09win.addEventListener%28%22dialogcancel%22%2C%20onDialogCancel%2C%20false%29%3B%0A%09%09win.addEventListener%28%22beforeunload%22%2C%20checkUnsaved%2C%20false%29%3B%0A%09%09win.addEventListener%28%22unload%22%2C%20destroy%2C%20false%29%3B%0A%09%7D%2C%20false%29%3B%0A%7D%3B%0Afunction%20unwrap%28o%29%20%7B%0A%09return%20o.wrappedJSObject%20%7C%7C%20o%3B%20//%20Firefox%203.6%20and%20older%0A%7D%0Afunction%20getStdImage%28iid%29%20%7B%0A%09if%28/%5Ecustombuttons-stdicon-%28%5Cd%29%24/.test%28iid%29%29%20switch%28+RegExp.%241%29%20%7B%0A%09%09//%20chrome%3A//custombuttons/skin/custombuttons.css%0A%09%09//%20toolbarbutton%5Bcb-stdicon%3D%22custombuttons-stdicon-*%22%5D%20%7B%20...%20%7D%0A%09%09case%201%3A%20return%20%22chrome%3A//custombuttons/skin/button.png%22%3B%0A%09%09case%202%3A%20return%20%22chrome%3A//custombuttons/skin/stdicons/rbutton.png%22%3B%0A%09%09case%203%3A%20return%20%22chrome%3A//custombuttons/skin/stdicons/gbutton.png%22%3B%0A%09%09case%204%3A%20return%20%22chrome%3A//custombuttons/skin/stdicons/bbutton.png%22%3B%0A%09%7D%0A%09return%20iid%20%7C%7C%20%22chrome%3A//custombuttons/skin/button.png%22%3B%0A%7D%0A%0Afunction%20initSessionStore%28%29%20%7B%0A%09initSessionStore%20%3D%20function%28%29%20%7B%7D%3B%0A%09var%20ss%20%3D%20%22nsISessionStore%22%20in%20Components.interfaces%0A%09%09%3F%20%28%0A%09%09%09Components.classes%5B%22@mozilla.org/browser/sessionstore%3B1%22%5D%0A%09%09%09%7C%7C%20Components.classes%5B%22@mozilla.org/suite/sessionstore%3B1%22%5D%0A%09%09%29.getService%28Components.interfaces.nsISessionStore%29%0A%09%09%3A%20SessionStore%3B%20//%20Firefox%2061+%20https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid%3D1450559%0A%09ss.persistTabAttribute%28cbIdTabAttr%29%3B%0A%7D%0Afunction%20checkTab%28tab%29%20%7B%0A%09var%20cbId%20%3D%20tab.getAttribute%28cbIdTabAttr%29%3B%0A%09if%28%21cbId%29%0A%09%09return%3B%0A%09initSessionStore%28%29%3B%0A%09let%20btn%20%3D%20document.getElementById%28cbId%29%3B%0A%09if%28btn%29%0A%09%09editCustomButtonInTab%28btn%2C%20tab%29%3B%0A%7D%0Aconst%20editorBaseUriLength%20%3D%20editorBaseUri.length%3B%0A//%20We%20can%27t%20use%20only%20SSTabRestoring%3A%20user%20can%20reload%20tab%20with%20editor%0AaddEventListener%28%22DOMContentLoaded%22%2C%20function%28e%29%20%7B%0A%09var%20doc%20%3D%20e.target%3B%0A%09if%28doc.location.href.substr%280%2C%20editorBaseUriLength%29%20%21%3D%20editorBaseUri%29%0A%09%09return%3B%0A%09var%20tabs%20%3D%20gBrowser.tabs%20%7C%7C%20gBrowser.tabContainer.childNodes%3B%0A%09for%28var%20i%20%3D%200%2C%20l%20%3D%20tabs.length%3B%20i%20%3C%20l%3B%20++i%29%20%7B%0A%09%09let%20tab%20%3D%20tabs%5Bi%5D%3B%0A%09%09let%20browser%20%3D%20tab.linkedBrowser%3B%0A%09%09if%28browser%20%26%26%20browser.contentDocument%20%3D%3D%20doc%29%20%7B%0A%09%09%09checkTab%28tab%29%3B%0A%09%09%09break%3B%0A%09%09%7D%0A%09%7D%0A%7D%2C%20true%2C%20document.getElementById%28%22appcontent%22%29%29%3B%20//%20Firefox%2060+%2C%20gBrowser%20isn%27t%20a%20DOM%20node%20anymore%20%0AcheckTab%28gBrowser.selectedTab%29%3B%0A%0Afunction%20destructor%28reason%29%20%7B%0A%09if%28reason%20%3D%3D%20%22update%22%20%7C%7C%20reason%20%3D%3D%20%22delete%22%29%20%7B%0A%09%09Array.prototype.slice.call%28document.getElementsByAttribute%28%22cb_id%22%2C%20editInTabId%29%29.forEach%28function%28btn%29%20%7B%0A%09%09%09btn.parentNode.removeChild%28btn%29%3B%0A%09%09%7D%29%3B%0A%09%09delete%20window.editCustomButtonInTab%3B%0A%09%7D%0A%7D%0Aif%28%0A%09typeof%20addDestructor%20%3D%3D%20%22function%22%20//%20Custom%20Buttons%200.0.5.6pre4+%0A%09%26%26%20addDestructor%20%21%3D%20%28%22addDestructor%22%20in%20window%20%26%26%20window.addDestructor%29%0A%29%0A%09addDestructor%28destructor%2C%20this%29%3B%0Aelse%0A%09this.onDestroy%20%3D%20destructor%3B%5D%5D%3E%3C/initcode%3E%0A%20%20%3Ccode%3E%3C%21%5BCDATA%5B/*CODE*/%5D%5D%3E%3C/code%3E%0A%20%20%3Caccelkey%3E%3C%21%5BCDATA%5B%5D%5D%3E%3C/accelkey%3E%0A%20%20%3Chelp%3E%3C%21%5BCDATA%5B%5D%5D%3E%3C/help%3E%0A%20%20%3Cattributes/%3E%0A%3C/custombutton%3E"
>Install</a>
| <a href="https://github.com/Infocatcher/Custom_Buttons/tree/master/Edit_Custom_Button_in_Tab">Source</a>
| <a href="https://github.com/Infocatcher/Custom_Buttons#usage">Instructions</a>
<script type="text/javascript">
var a = document.getElementsByTagName("a")[0];
a.title = document.title;
if(/%3Cimage%3E%3C%21%5BCDATA%5B(data%3A\S+)%5D%5D%3E%3C\/image%3E/.test(a.href)) {
var icon = decodeURIComponent(RegExp.$1);
var img = document.createElement("img");
img.src = icon;
img.alt = "";
img.style.verticalAlign = "middle";
img.style.marginRight = "4px";
img.style.border = "none";
a.insertBefore(img, a.firstChild);
var link = document.createElement("link");
link.rel = "shortcut icon";
link.href = icon;
document.documentElement.insertBefore(link, document.documentElement.firstChild);
}
</script>
<script type="text/javascript" src="https://infocatcher.github.io/Custom_Buttons/viewCustomButton.js"></script>
<script type="text/javascript">
if("viewCustomButtonCode" in window) setTimeout(function() {
viewCustomButtonCode(a.href);
}, 0);
</script>
</body>