Отвалилась кнопка Custom Buttons при переходе на версию ESR 91.0.1 .
Есть какое решение?
Win7
Отсутствует
надо было сразу указать, что мой вопрос для крайней версии .
Да много чего надо было сразу указать.
Возню затеял, но капитально застрял на перетаскивании вкладок,
лисий вариант не рассчитан на то, что вкладки могут быть разной ширины.
Можно вас попросить добавить еще открытие закладки в контейнере?
Чтобы ЛКМ по закладке отрывал ее в контейнере (название для контейнера бралось с названия папки в которой находится закладка)
Можно попробовать добавить в конец метода init() что-то типа такого
....... var {PlacesUtils} = ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm"); var {PrivateBrowsingUtils} = ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); ChromeUtils.import( "resource:///modules/PlacesUIUtils.jsm" ).PlacesUIUtils._openNodeIn = function PUIU__openNodeIn(node, where, win, priv) { if (node && PlacesUtils.nodeIsURI(node) && this.checkURLSecurity(node, win)) { var {uri} = node; var isBookmark = PlacesUtils.nodeIsBookmark(node); if (!PrivateBrowsingUtils.isWindowPrivate(win)) isBookmark ? this.markPageAsFollowedBookmark(uri) : this.markPageAsTyped(uri); var params = {private: priv, inBackground: this.loadBookmarksInBackground}; if (uri.startsWith("javascript:")) params.allowPopups = params.allowInheritPrincipal = true; else if (isBookmark) { var e = win.event; if ( e && !e.button && e.detail <= 1 && !e.ctrlKey && !e.shiftKey && !e.altKey && (e.type == "command" || e.type == "click") && e.target.matches(".bookmark-item, treechildren") ) { if (where == "current") where = "tab"; var title, {parent} = node, {type} = parent; var folder = type == node.RESULT_TYPE_FOLDER || type == node.RESULT_TYPE_FOLDER_SHORTCUT; if (folder) title = PlacesUtils.bookmarks.getLocalizedTitle({ guid: parent.bookmarkGuid, title: parent.title }); var id = params.userContextId = self.newUsercontext(title); folder || updateTitle(id, node.bookmarkGuid); } } win.openTrustedLinkIn(uri, where, params); } } var updateTitle = async (id, guid) => { var {parentGuid} = await PlacesUtils.bookmarks.fetch(guid); var title = PlacesUtils.bookmarks.getLocalizedTitle( await PlacesUtils.bookmarks.fetch(parentGuid) ); var {icon, color} = this.cis.getPublicIdentityFromId(id); this.cis.update(id, title, icon, color); }
после установки внизу браузера постоянно висит надпись "xmlns-http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">"
Значит в профиле, в папке custombuttons, прописался <parsererror>,
и сам никуда не исчезнет. Следует вручную убедиться, что на момент
запуска расширения ничего подобного там нет.
Где эта настройка ? Все облазил и не могу найти. "переключаться на вкладку..."
Если разрешение есть, то пишется в файл permissions.sqlite в профиле.
В таблице moz_perms, в строке,
содержащей в колонке origin значение https://filmix.ac
и содержащей в колонке type значение focus-tab-by-prompt
Наличие разрешения проверяется listener'ом на событие "DOMWillOpenModalDialog",
который регистрируется методом gBrowser._setupEventListeners().
Файл: chrome://browser/content/tabbrowser.js
он же %FOX%\browser\omni.ja\chrome\browser\content\browser\tabbrowser.js
Отвалилась кнопка
Есть какое решение?
Нет. Телепатов не существует.
Существуют, наверно, крутые угадальщики,
но здесь, даже они, вряд ли что-то смогут поделать.
Отсутствует
Dumby
Опять снова здорово...Приморила aboutaddons.js . Дв.клик по пустоте и появляется это:
Заманало стилями убирать и в префке тоже...
Боюсь это только с custombutton связано , длину card уменьшил...просто клик и эта шняга...
Снят вопрос. В view-controller.js было return "addons://discover/"; Пришлось другое подставить...А. нельзя на глушняк избавиться от discover ?
Отредактировано ВВП (24-08-2021 22:15:16)
Отсутствует
Можно попробовать добавить в конец метода init() что-то типа такого
....... var {PlacesUtils} = ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm"); var {PrivateBrowsingUtils} = ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); ChromeUtils.import( "resource:///modules/PlacesUIUtils.jsm" ).PlacesUIUtils._openNodeIn = function PUIU__openNodeIn(node, where, win, priv) { if (node && PlacesUtils.nodeIsURI(node) && this.checkURLSecurity(node, win)) { var {uri} = node; var isBookmark = PlacesUtils.nodeIsBookmark(node); if (!PrivateBrowsingUtils.isWindowPrivate(win)) isBookmark ? this.markPageAsFollowedBookmark(uri) : this.markPageAsTyped(uri); var params = {private: priv, inBackground: this.loadBookmarksInBackground}; if (uri.startsWith("javascript:")) params.allowPopups = params.allowInheritPrincipal = true; else if (isBookmark) { var e = win.event; if ( e && !e.button && e.detail <= 1 && !e.ctrlKey && !e.shiftKey && !e.altKey && (e.type == "command" || e.type == "click") && e.target.matches(".bookmark-item, treechildren") ) { if (where == "current") where = "tab"; var title, {parent} = node, {type} = parent; var folder = type == node.RESULT_TYPE_FOLDER || type == node.RESULT_TYPE_FOLDER_SHORTCUT; if (folder) title = PlacesUtils.bookmarks.getLocalizedTitle({ guid: parent.bookmarkGuid, title: parent.title }); var id = params.userContextId = self.newUsercontext(title); folder || updateTitle(id, node.bookmarkGuid); } } win.openTrustedLinkIn(uri, where, params); } } var updateTitle = async (id, guid) => { var {parentGuid} = await PlacesUtils.bookmarks.fetch(guid); var title = PlacesUtils.bookmarks.getLocalizedTitle( await PlacesUtils.bookmarks.fetch(parentGuid) ); var {icon, color} = this.cis.getPublicIdentityFromId(id); this.cis.update(id, title, icon, color); }
(async (sel, self) => ({ icon: "circle", colors: [ "#FF9800", "#03A9F4", "#FFC107", "#00BCD4", "#FFEB3B", "#009688", "#CDDC39", "#4CAF50", "#8BC34A", "#D32F2F", "#4949ff", "#C2185B", "#607D8B", "#7B1FA2", "#9E9E9E", "#673AB7", "#795548", "#3F51B5", "#FF5722", "#2196F3", ], initColors() { var colorName = "ucf-gen"; var css = "@-moz-document url(about:preferences#containers)," + " url-prefix(chrome://browser/content/browser.x) {\n"; this.colors.forEach((color, ind) => { var [ic, tc] = color.split(/\s*\|\s*/); css += `\t.identity-color-${colorName}${ind} {\n` + `\t\t--identity-tab-color: ${tc || ic};\n` + `\t\t--identity-icon-color: ${ic};\n\t}\n` }); var url = "data:text/css;charset=utf-8," + encodeURIComponent(css + "}"); var sss = Cc["@mozilla.org/content/style-sheet-service;1"] .getService(Ci.nsIStyleSheetService); sss.loadAndRegisterSheet(Services.io.newURI(url), sss.USER_SHEET); var len = this.colors.length; var pref = "ucf.openInGeneratedContainer.lastColor"; var ind = Math.min(Services.prefs.getIntPref(pref, -1), len - 1); this.nextColor = () => { var next = ind + 1; Services.prefs.setIntPref(pref, ind = next == len ? 0 : next); return colorName + ind; } }, quit: false, init(topic) { Services.obs.addObserver(self = this, topic); var lt = "browser-lastwindow-close-granted"; var lw = () => this.quit = true; Services.obs.addObserver(lw, lt); Services.obs.addObserver(function quit(s, t) { self.quit = true; Services.obs.removeObserver(self, topic); Services.obs.removeObserver(lw, lt); Services.obs.removeObserver(quit, t); }, "quit-application-granted"); this.initColors(); this.newUsercontext = name => { var id = this.cis.create( name || `[ ${this.cis._lastUserContextId + 1} ]`, this.icon, this.nextColor() ).userContextId; this.saveGens(this.gens.add(id)); return id; } var cpref = "ucf.openInGeneratedContainer.containers"; var arr = Services.prefs.getStringPref(cpref, "").split(",").map(Number).filter(Boolean); if (arr.length) { var ids = this.cis.getPublicIdentities().map(i => i.userContextId); arr = arr.filter(id => ids.includes(id)); } this.gens = new Set(arr); (this.saveGens = () => Services.prefs.setStringPref(cpref, Array.from(this.gens).join(",")))(); }, observe(doc) { var list = doc.querySelectorAll(sel); if (!list.length) return; var menuitem = doc.createXULElement("menuitem"); for(var args of Object.entries({ selectiontype: "single", oncommand: "cmd(window)", nodetype: "folder|query", selection: "folder|query", label: "Открыть всё в контейнере", id: "placesContext_openContainer:tabs:newUsercontext" })) menuitem.setAttribute(...args); menuitem.cmd = this.cmd; menuitem.rnd = menuitem.constructor.prototype.render; menuitem.render = this.render; var [m1, m2] = menuitem.list = Array.from(list); (m2 || m1).after(menuitem); if (doc.documentElement.getAttribute("windowtype") != "navigator:browser") return; for(var btn of [ doc.getElementById("tabs-newtab-button"), doc.getElementById("new-tab-button") || doc.ownerGlobal.gNavToolbox.palette.querySelector("#new-tab-button") ]) if (btn) btn.checkForMiddleClick = this.click; var win = doc.ownerGlobal; this.redefDoSearch(win, win.customElements.get("searchbar").prototype); win.gBrowser.tabContainer.addEventListener("TabClose", this.tabClose); win.addEventListener("unload", this.winUnload, {once: true}); this.quit = false; var tuc = "gBrowser.selectedTab.userContextId"; win.BrowserOpenTab = win.eval(`(${win.BrowserOpenTab})`.replace( "resolve,", `$&\n userContextId: ${tuc},` )); var bdw = win.browserDOMWindow.wrappedJSObject; win.Object.assign(bdw, win.eval( `({${bdw.getContentWindowOrOpenURI}})` .replace("userContextId,", `isExternal ? ${tuc} : $&`) .replace( /null,\s+null,\s+null,\s+aTriggeringPrincipal/, `isExternal ? ${tuc} : $&` ) )); }, winUnload(e) { var win = e.target.ownerGlobal; win.removeEventListener("TabClose", self.tabClose); if (self.quit) return; var gb = win.gBrowser; if (gb) for(var tab of gb.tabs) self.tabClose(null, tab); }, closed: new Set(), cis: ChromeUtils.import("resource://gre/modules/ContextualIdentityService.jsm") .ContextualIdentityService, tabClose(e, tab = e.target) { var id = +tab.getAttribute("usercontextid"); id && self.gens.has(id) && self.closed.add(id); self.closed.size == 1 && ChromeUtils.idleDispatch(self.maybeRemove); }, maybeRemove() { var ids = Array.from(self.closed); self.closed.clear(); for(var id of ids) self.maybeRemoveById(id); }, maybeRemoveById(id) { for(var win of CustomizableUI.windows) if (win.document.querySelector(`tab.tabbrowser-tab[usercontextid="${id}"]`)) return; this.saveGens(this.gens.delete(id)); this.cis.remove(id); }, redefDoSearch(win, proto) { var code = `(openTrustedLinkIn => [ {${proto.doSearch}}, openTrustedLinkIn ])( function otl(url, where, params) { if (where != "current") params.resolveOnNewTabCreated = br => { var tab = gBrowser.getTabForBrowser(br); gBrowser.moveTabTo(tab, Infinity); gBrowser.addTrustedTab("about:blank", { index: tab._tPos, userContextId: tab.userContextId }); }, params.userContextId = otl.newUsercontext( document.getElementById("searchbar").value ); openTrustedLinkIn(url, where, params); } );`; (this.redefDoSearch = (win, proto) => { var [obj, func] = win.eval(code); Object.assign(proto, obj); func.newUsercontext = this.newUsercontext; })(win, proto); }, click(btn, e) { if (!(e.button != 2 || e.ctrlKey || e.shiftKey)) { var txt = e.view.readFromClipboard(); if (txt) { var urls = txt.split("\n").map(self.map).filter(Boolean); if (urls.length) return e.preventDefault(), self.openFromClipboard(e.view, urls); } } e.view.checkForMiddleClick(btn, e); }, eo: Object.create(null), map(str) { str = str.trim(); try { var scheme = Services.io.extractScheme(str); var ph = Services.io.getProtocolHandler(scheme); if (ph.scheme == scheme) return Services.io.newURI(str) && {uri: str}; } catch {} }, openFromClipboard(win, urls) { if (win.OpenInTabsUtils.confirmOpenInTabs(urls.length, win)) urls.load = true, this.open(win, this.eo, urls); }, async render() { this.rnd(); await new Promise(this.ownerGlobal.requestAnimationFrame); this.hidden || (this.hidden = this.list.every(self.every)); }, every: node => node.disabled || node.hidden, cmd(win) { var {_view, triggerNode} = this.parentNode; var node = triggerNode._placesView && triggerNode._placesView.result.root; self.open(win, node || _view.selectedNode || _view.result.root); }, open(win, node, list) { var gbw = Cu.import("resource:///modules/PlacesUIUtils.jsm", {}).getBrowserWindow; var w = gbw(win); this.pu = w.PlacesUIUtils; this.fs = w.PlacesUtils.favicons; this.sysp = w.E10SUtils.SERIALIZED_SYSTEMPRINCIPAL; (this.open = (win, node, list) => { var {bookmarkGuid: guid, title} = node; if (guid && title) title = win.PlacesUtils.bookmarks.getLocalizedTitle({guid, title}); this.openURLs(gbw(win), list || win.PlacesUtils.getURLsForContainerNode(node), title); guid && this.pu.doCommand(win, "placesCmd_delete"); })(win, node, list); }, async openURLs(win, urls, title) { var userContextId = this.newUsercontext(title); var mark = !win.PrivateBrowsingUtils.isWindowPrivate(win); var {load} = urls, gb = win.gBrowser, pos = gb.selectedTab._tPos; for(var {uri, title, isBookmark} of urls) try { if (mark) isBookmark ? this.pu.markPageAsFollowedBookmark(uri) : this.pu.markPageAsTyped(uri); if (load) { gb.addTrustedTab(uri, {index: ++pos, userContextId}); continue; } var state = {userContextId, entries: [{ url: uri, title: title || uri, triggeringPrincipal_base64: this.sysp }]}; var [,, data, mime] = await new Promise( resolve => this.fs.getFaviconDataForPage( Services.io.newURI(uri), (...args) => resolve(args), 16 ) ); if (data.length) state.image = `data:${ mime || "image/x-icon" };base64,${ btoa(String.fromCharCode(...data)) }`; var tab = gb.addTrustedTab(null, {index: ++pos, userContextId}); win.SessionStore.setTabState(tab, state); } catch {}; } }).init("chrome-document-loaded"))( "#placesContext_openBookmarkContainer\\:tabs,#placesContext_openContainer\\:tabs" );
Отредактировано Stkvsky (24-08-2021 21:21:42)
Отсутствует
Alex_one
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%3EZoom%3C/name%3E%0A%20%20%3Cimage%3E%3C%21%5BCDATA%5Bdata%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB+0lEQVR42qWSS2sTYRSGn1AlIvWCYjBKm40LF4KXRTeKIMFNxcvChWsve0P9ASJdCCIDUpxFFVrI0kZtCqEwgUKxRUpIWtJSNLRam/RCElKJEDVxfCcZ1JS2BDzw8s13e+a85zue+/xfeLYDGBMTJRYWyszOVsnlAqHBQU/LgDtw49Tc3GvW12FqCiIRzMnJqx9gpCWAMTCwRmenj6UlGB+HoSHWSiUe63yrAJt8HqVfB2xkMigXnsMRDfkdAUZ3t0VXV5BEAqLRYhaqVfBVtLcKM2/g9M4A07SZn4d4nIfp9OVjcOIKmD+1Z0vPNtloAjyAu8f7+vpJJiEWI5TL1Q8/0t1fGn9I7+FlXOe2BBjhsM3iIoyNkYjHh8Nw3Vm/BW/PwTXHxob09J8s/gDOw5mbppkkldJjjRDKZptSNdra7EqtRknfEbj3EV40AYze3gLl8iFGRynIQsH1vFfaJ+2WHBvfpK+S6WbxF9DTY2NZfJmeRvT6nxzAQWm/1C55pZoLicLZIqTqAKOjw8LrDX7We6c1V5Fu74GAU7QD0q4GbPkS9OMW8zsUY3C4AfD77dWVFeQeNe5w0S3e5lAhLR8Eq+7ckgPPK73eBXiS0YJ6nRnwN3pm67ioZCpuPZTJO48ulZelT+o49Wh7rmF72zgp37p8VBYqshf4DWzUxjD6mvoSAAAAAElFTkSuQmCC%5D%5D%3E%3C/image%3E%0A%20%20%3Cmode%3E0%3C/mode%3E%0A%20%20%3Cinitcode%3E%3C%21%5BCDATA%5B/*Initialization%20Code*/%0A//%20%u041A%u043D%u043E%u043F%u043A%u0430%20%u0434%u043B%u044F%20%u0443%u043F%u0440%u0430%u0432%u043B%u0435%u043D%u0438%u044F%20%u043C%u0430%u0441%u0448%u0442%u0430%u0431%u043E%u043C%20%u0441%u0442%u0440%u0430%u043D%u0438%u0446%u044B%20%u0432%20%u0430%u0434%u0440%u0435%u0441%u043D%u043E%u0439%20%u0441%u0442%u0440%u043E%u043A%u0435%0A%0A//%20%u041D%u0430%u0441%u0442%u0440%u043E%u0439%u043A%u0430%20%u0444%u0443%u043D%u043A%u0446%u0438%u0439%20%u043A%u043B%u0438%u043A%u043E%u0432%20%u043C%u044B%u0448%u0438%20%u0434%u043B%u044F%20%u043A%u043D%u043E%u043F%u043A%u0438%20..............%0Athis.onclick%20%3D%20this.oncontextmenu%20%3D%20function%28event%29%20%7B%0Aif%20%28event.button%20%3D%3D%200%29%20%7B%0AFullZoom.enlarge%28%29%3B%3B%0A%0A%0A%7D%0A%0A%20%20%20%20%20%20%20%20if%28event.button%20%3D%3D%201%20%26%26%20%21event.ctrlKey%20%26%26%20%21event.shiftKey%20%26%26%20%21event.altKey%20%26%26%20%21event.metaKey%29%7B%0A%0A%20%20%20%20%20%20%20%28lc%20%3D%3E%20%7B%0A%09var%20%7B_cps2%2C%20name%7D%20%3D%20FullZoom%3B%0A%09_cps2.removeByName%28name%2C%20lc%2C%20%7BhandleCompletion%28%29%20%7B%0A%09%09_cps2.setGlobal%28name%2C%201.0%2C%20lc%29%3B%0A%09%09for%28var%20%5Burl%2C%20zoom%5D%20of%20Object.entries%28%7B%0A%0A%09%09%09%0A%09%09%09%0A%09%09%7D%29%29%0A%09%09%09_cps2.set%28_cps2.extractDomain%28url%29%2C%20name%2C%20zoom%2C%20lc%29%3B%0A%09%7D%7D%29%3B%0A%7D%29%28Cu.createLoadContext%28%29%29%3B%0A%0A%20%20%20%20%20%20%20var%20s%20%3D%20%22browser.zoom.updateBackgroundTabs%22%3B%0A%20%20%20%20%20%20cbu.setPrefs%28s%2C%20cbu.getPrefs%28s%29%20%3D%3D%20true%20%3F%20false%20%3A%20true%29%3B%20%0A%0A%20%20%20%20%20%20%20%20%20%20%0A%7D%20%0Aif%28event.button%20%3D%3D%202%20%26%26%20%21event.ctrlKey%20%26%26%20%21event.shiftKey%20%26%26%20%21event.altKey%20%26%26%20%21event.metaKey%29%7B%0A%0AFullZoom.reduce%28%29%3B%0A%7D%0A%7D%3B%0Athis.oncontextmenu%20%3De%3D%3E%20%7B%20e.button%20%26%26%20%21e.ctrlKey%20%26%26%20e.preventDefault%28%29%20%7D%3B%0A%0A//%20%u041F%u043E%u0434%u0441%u043A%u0430%u0437%u043A%u0430%20%u0434%u043B%u044F%20%u043A%u043D%u043E%u043F%u043A%u0438%20..............%0Athis.onmouseover%20%3D%28%29%3D%3E%20%7B%0A%20%20%20var%20value%20%3D%20Math.floor%28%28ZoomManager.zoom%20+%200.005%29%20*%20100%29%20%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20this.tooltipText%20%3D%20%22%u041B%u041A%u041C%3A%20%u0443%u0432%u0435%u043B%u0438%u0447%u0438%u0442%u044C%20%u043C%u0430%u0441%u0448%u0442%u0430%u0431%20%5Cn%u041F%u041A%u041C%3A%20%u0443%u043C%u0435%u043D%u044C%u0448%u0438%u0442%u044C%20%u043C%u0430%u0441%u0448%u0442%u0430%u0431%5Cn%u0421%u041A%u041C%3A%20%u0421%u0432%u043E%u0439%20%u043C%u0430%u0441%u0448%u0442%u0430%u0431%2C%20%u0441%u043A%u0438%u043D%u0443%u0442%u044C%20%u043C%u0430%u0441%u0448%u0442%u0430%u0431%u044B%22%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%7D%3B%0A//%20%u0423%u0441%u0442%u0430%u043D%u043E%u0432%u0438%u0442%u044C%20%u043D%u0443%u0436%u043D%u0443%u044E%20%u0438%u043A%u043E%u043D%u043A%u0443%20%u043A%u043D%u043E%u043F%u043A%u0438%20%u043F%u0440%u0438%20%u0441%u0442%u0430%u0440%u0442%u0435%20%u0431%u0440%u0430%u0443%u0437%u0435%u0440%u0430%20%u0438%u043B%u0438%20%u043F%u0440%u0438%20%u0438%u0437%u043C%u0435%u043D%u0435%u043D%u0438%u044F%u0445%20%u043D%u0430%u0441%u0442%u0440%u043E%u0435%u043A%20%27about%3Aconfig%27%20..............%0Avar%20zoomFull%20%3D%20%22browser.zoom.updateBackgroundTabs%22%3B%0Afunction%20toggleImage%28%29%20%7B%0A%20%20%20self.image%20%3D%20cbu.getPrefs%28zoomFull%29%0A%20%20%20%3F%20%27data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB+0lEQVR42qWSS2sTYRSGn1AlIvWCYjBKm40LF4KXRTeKIMFNxcvChWsve0P9ASJdCCIDUpxFFVrI0kZtCqEwgUKxRUpIWtJSNLRam/RCElKJEDVxfCcZ1JS2BDzw8s13e+a85zue+/xfeLYDGBMTJRYWyszOVsnlAqHBQU/LgDtw49Tc3GvW12FqCiIRzMnJqx9gpCWAMTCwRmenj6UlGB+HoSHWSiUe63yrAJt8HqVfB2xkMigXnsMRDfkdAUZ3t0VXV5BEAqLRYhaqVfBVtLcKM2/g9M4A07SZn4d4nIfp9OVjcOIKmD+1Z0vPNtloAjyAu8f7+vpJJiEWI5TL1Q8/0t1fGn9I7+FlXOe2BBjhsM3iIoyNkYjHh8Nw3Vm/BW/PwTXHxob09J8s/gDOw5mbppkkldJjjRDKZptSNdra7EqtRknfEbj3EV40AYze3gLl8iFGRynIQsH1vFfaJ+2WHBvfpK+S6WbxF9DTY2NZfJmeRvT6nxzAQWm/1C55pZoLicLZIqTqAKOjw8LrDX7We6c1V5Fu74GAU7QD0q4GbPkS9OMW8zsUY3C4AfD77dWVFeQeNe5w0S3e5lAhLR8Eq+7ckgPPK73eBXiS0YJ6nRnwN3pm67ioZCpuPZTJO48ulZelT+o49Wh7rmF72zgp37p8VBYqshf4DWzUxjD6mvoSAAAAAElFTkSuQmCC%27%0A%20%20%20%3A%20%27data%3Aimage/png%3Bcharset%3Dutf-8%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA7UlEQVR42mNkoBAw4pb6/wFIfAHiP0AsD1TKSIIB/wOAxHo0QV+g8i3EGvASSIhhsY+RWAP+4/CXKFDLGwIG/N8DJJyhnHfQMIC55hJQiz4hA5BtdwViFSCejssbaAb8TwESszEVoxg6FyiegssAZIWbgNL+UPGNQMIPmyuQDPhvACTO4w5xFMNTgfJz0A14CySEGIgGEAuQDfhPvGYwMARqvwALJOSoA4EkBnDyRQFPUAMYFMWMwthCGSnw0AG6RYwgf/wvAbK6kVRJAiVe4HY5imVHQQaAchws1/EANQvg9/r/C0BCAoh/gLwJAA1PPtKQq6hOAAAAAElFTkSuQmCC%27%3B%0A%7D%0AtoggleImage%28%29%3B%0AServices.prefs.addObserver%28zoomFull%2C%20toggleImage%2C%20false%29%3B%0AaddDestructor%28%28%29%3D%3E%20Services.prefs.removeObserver%28zoomFull%2C%20toggleImage%29%20%29%3B%0A%20%0Avar%20style%20%3D%20custombutton.buttonGetHelp%28self%29.replace%28/id/g%2C%20_id%29%3B%0Avar%20uri%20%3D%20makeURI%28%27data%3Atext/css%2C%27+%20encodeURIComponent%28style%29%29%3B%0Avar%20sss%20%3D%20Cc%5B%22@mozilla.org/content/style-sheet-service%3B1%22%5D.getService%28Ci.nsIStyleSheetService%29%3B%0Asss.loadAndRegisterSheet%28uri%2C%200%29%3B%20%0A%0A%5D%5D%3E%3C/initcode%3E%0A%20%20%3Ccode%3E%3C%21%5BCDATA%5B/*CODE*/%0A%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
Увеличить изображение не будет работать без рихтовки в модулях ("resource://gre/modules/BrowserUtils.jsm")
/* -*- mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; var EXPORTED_SYMBOLS = ["BrowserUtils"]; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); ChromeUtils.defineModuleGetter( this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm" ); // The maximum number of concurrently-loaded origins allowed in order to // qualify for the Fission rollout experiment. XPCOMUtils.defineLazyPreferenceGetter( this, "fissionExperimentMaxOrigins", "fission.experiment.max-origins.origin-cap", 30 ); // The length of the sliding window during which a user must stay below // the max origin cap. If the last time a user passed the max origin cap // fell outside of this window, they will requalify for the experiment. XPCOMUtils.defineLazyPreferenceGetter( this, "fissionExperimentSlidingWindowMS", "fission.experiment.max-origins.sliding-window-ms", 7 * 24 * 60 * 60 * 1000 ); // The pref holding the current qaualification state of the user. If // true, the user is currently qualified from the experiment. const FISSION_EXPERIMENT_PREF_QUALIFIED = "fission.experiment.max-origins.qualified"; XPCOMUtils.defineLazyPreferenceGetter( this, "fissionExperimentQualified", FISSION_EXPERIMENT_PREF_QUALIFIED, false ); // The pref holding the timestamp of the last time we saw an origin // count below the cap while the user was not currently marked as // qualified. const FISSION_EXPERIMENT_PREF_LAST_QUALIFIED = "fission.experiment.max-origins.last-qualified"; XPCOMUtils.defineLazyPreferenceGetter( this, "fissionExperimentLastQualified", FISSION_EXPERIMENT_PREF_LAST_QUALIFIED, 0 ); // The pref holding the timestamp of the last time we saw an origin // count exceeding the cap. const FISSION_EXPERIMENT_PREF_LAST_DISQUALIFIED = "fission.experiment.max-origins.last-disqualified"; XPCOMUtils.defineLazyPreferenceGetter( this, "fissionExperimentLastDisqualified", FISSION_EXPERIMENT_PREF_LAST_DISQUALIFIED, 0 ); var BrowserUtils = { /** * Prints arguments separated by a space and appends a new line. */ dumpLn(...args) { for (let a of args) { dump(a + " "); } dump("\n"); }, /** * restartApplication: Restarts the application, keeping it in * safe mode if it is already in safe mode. */ restartApplication() { let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance( Ci.nsISupportsPRBool ); Services.obs.notifyObservers( cancelQuit, "quit-application-requested", "restart" ); if (cancelQuit.data) { // The quit request has been canceled. return false; } // if already in safe mode restart in safe mode if (Services.appinfo.inSafeMode) { Services.startup.restartInSafeMode( Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart ); return undefined; } Services.startup.quit( Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart ); return undefined; }, /** * Check whether a page can be considered as 'empty', that its URI * reflects its origin, and that if it's loaded in a tab, that tab * could be considered 'empty' (e.g. like the result of opening * a 'blank' new tab). * * We have to do more than just check the URI, because especially * for things like about:blank, it is possible that the opener or * some other page has control over the contents of the page. * * @param {Browser} browser * The browser whose page we're checking. * @param {nsIURI} [uri] * The URI against which we're checking (the browser's currentURI * if omitted). * * @return {boolean} false if the page was opened by or is controlled by * arbitrary web content, unless that content corresponds with the URI. * true if the page is blank and controlled by a principal matching * that URI (or the system principal if the principal has no URI) */ checkEmptyPageOrigin(browser, uri = browser.currentURI) { // If another page opened this page with e.g. window.open, this page might // be controlled by its opener. if (browser.hasContentOpener) { return false; } let contentPrincipal = browser.contentPrincipal; // Not all principals have URIs... // There are two special-cases involving about:blank. One is where // the user has manually loaded it and it got created with a null // principal. The other involves the case where we load // some other empty page in a browser and the current page is the // initial about:blank page (which has that as its principal, not // just URI in which case it could be web-based). Especially in // e10s, we need to tackle that case specifically to avoid race // conditions when updating the URL bar. // // Note that we check the documentURI here, since the currentURI on // the browser might have been set by SessionStore in order to // support switch-to-tab without having actually loaded the content // yet. let uriToCheck = browser.documentURI || uri; if ( (uriToCheck.spec == "about:blank" && contentPrincipal.isNullPrincipal) || contentPrincipal.spec == "about:blank" ) { return true; } if (contentPrincipal.isContentPrincipal) { return contentPrincipal.equalsURI(uri); } // ... so for those that don't have them, enforce that the page has the // system principal (this matches e.g. on about:newtab). return contentPrincipal.isSystemPrincipal; }, /** * urlSecurityCheck: JavaScript wrapper for checkLoadURIWithPrincipal * and checkLoadURIStrWithPrincipal. * If |aPrincipal| is not allowed to link to |aURL|, this function throws with * an error message. * * @param aURL * The URL a page has linked to. This could be passed either as a string * or as a nsIURI object. * @param aPrincipal * The principal of the document from which aURL came. * @param aFlags * Flags to be passed to checkLoadURIStr. If undefined, * nsIScriptSecurityManager.STANDARD will be passed. */ urlSecurityCheck(aURL, aPrincipal, aFlags) { var secMan = Services.scriptSecurityManager; if (aFlags === undefined) { aFlags = secMan.STANDARD; } try { if (aURL instanceof Ci.nsIURI) { secMan.checkLoadURIWithPrincipal(aPrincipal, aURL, aFlags); } else { secMan.checkLoadURIStrWithPrincipal(aPrincipal, aURL, aFlags); } } catch (e) { let principalStr = ""; try { principalStr = " from " + aPrincipal.spec; } catch (e2) {} throw new Error(`Load of ${aURL + principalStr} denied.`); } }, /** * Return or create a principal with the content of one, and the originAttributes * of an existing principal (e.g. on a docshell, where the originAttributes ought * not to change, that is, we should keep the userContextId, privateBrowsingId, * etc. the same when changing the principal). * * @param principal * The principal whose content/null/system-ness we want. * @param existingPrincipal * The principal whose originAttributes we want, usually the current * principal of a docshell. * @return an nsIPrincipal that matches the content/null/system-ness of the first * param, and the originAttributes of the second. */ principalWithMatchingOA(principal, existingPrincipal) { // Don't care about system principals: if (principal.isSystemPrincipal) { return principal; } // If the originAttributes already match, just return the principal as-is. if (existingPrincipal.originSuffix == principal.originSuffix) { return principal; } let secMan = Services.scriptSecurityManager; if (principal.isContentPrincipal) { return secMan.principalWithOA( principal, existingPrincipal.originAttributes ); } if (principal.isNullPrincipal) { return secMan.createNullPrincipal(existingPrincipal.originAttributes); } throw new Error( "Can't change the originAttributes of an expanded principal!" ); }, /** * Constructs a new URI, using nsIIOService. * @param aURL The URI spec. * @param aOriginCharset The charset of the URI. * @param aBaseURI Base URI to resolve aURL, or null. * @return an nsIURI object based on aURL. * * @deprecated Use Services.io.newURI directly instead. */ makeURI(aURL, aOriginCharset, aBaseURI) { return Services.io.newURI(aURL, aOriginCharset, aBaseURI); }, /** * @deprecated Use Services.io.newFileURI directly instead. */ makeFileURI(aFile) { return Services.io.newFileURI(aFile); }, /** * For a given DOM element, returns its position in "screen" * coordinates. In a content process, the coordinates returned will * be relative to the left/top of the tab. In the chrome process, * the coordinates are relative to the user's screen. */ getElementBoundingScreenRect(aElement) { return this.getElementBoundingRect(aElement, true); }, /** * For a given DOM element, returns its position as an offset from the topmost * window. In a content process, the coordinates returned will be relative to * the left/top of the topmost content area. If aInScreenCoords is true, * screen coordinates will be returned instead. */ getElementBoundingRect(aElement, aInScreenCoords) { let rect = aElement.getBoundingClientRect(); let win = aElement.ownerGlobal; let x = rect.left; let y = rect.top; // We need to compensate for any iframes that might shift things // over. We also need to compensate for zooming. let parentFrame = win.frameElement; while (parentFrame) { win = parentFrame.ownerGlobal; let cstyle = win.getComputedStyle(parentFrame); let framerect = parentFrame.getBoundingClientRect(); x += framerect.left + parseFloat(cstyle.borderLeftWidth) + parseFloat(cstyle.paddingLeft); y += framerect.top + parseFloat(cstyle.borderTopWidth) + parseFloat(cstyle.paddingTop); parentFrame = win.frameElement; } rect = { left: x, top: y, width: rect.width, height: rect.height, }; rect = win.windowUtils.transformRectLayoutToVisual( rect.left, rect.top, rect.width, rect.height ); if (aInScreenCoords) { rect = { left: rect.left + win.mozInnerScreenX, top: rect.top + win.mozInnerScreenY, width: rect.width, height: rect.height, }; } let fullZoom = win.windowUtils.fullZoom; rect = { left: rect.left * fullZoom, top: rect.top * fullZoom, width: rect.width * fullZoom, height: rect.height * fullZoom, }; return rect; }, onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab) { // Don't modify non-default targets or targets that aren't in top-level app // tab docshells (isAppTab will be false for app tab subframes). if (originalTarget != "" || !isAppTab) { return originalTarget; } // External links from within app tabs should always open in new tabs // instead of replacing the app tab's page (Bug 575561) let linkHost; let docHost; try { linkHost = linkURI.host; docHost = linkNode.ownerDocument.documentURIObject.host; } catch (e) { // nsIURI.host can throw for non-nsStandardURL nsIURIs. // If we fail to get either host, just return originalTarget. return originalTarget; } if (docHost == linkHost) { return originalTarget; } // Special case: ignore "www" prefix if it is part of host string let [longHost, shortHost] = linkHost.length > docHost.length ? [linkHost, docHost] : [docHost, linkHost]; if (longHost == "www." + shortHost) { return originalTarget; } return "_blank"; }, /** * Map the plugin's name to a filtered version more suitable for UI. * * @param aName The full-length name string of the plugin. * @return the simplified name string. */ makeNicePluginName(aName) { if (aName == "Shockwave Flash") { return "Adobe Flash"; } // Regex checks if aName begins with "Java" + non-letter char if (/^Java\W/.exec(aName)) { return "Java"; } // Clean up the plugin name by stripping off parenthetical clauses, // trailing version numbers or "plugin". // EG, "Foo Bar (Linux) Plugin 1.23_02" --> "Foo Bar" // Do this by first stripping the numbers, etc. off the end, and then // removing "Plugin" (and then trimming to get rid of any whitespace). // (Otherwise, something like "Java(TM) Plug-in 1.7.0_07" gets mangled) let newName = aName .replace(/\(.*?\)/g, "") .replace(/[\s\d\.\-\_\(\)]+$/, "") .replace(/\bplug-?in\b/i, "") .trim(); return newName; }, /** * Returns true if |mimeType| is text-based, or false otherwise. * * @param mimeType * The MIME type to check. */ mimeTypeIsTextBased(mimeType) { return ( mimeType.startsWith("text/") || mimeType.endsWith("+xml") || mimeType == "application/x-javascript" || mimeType == "application/javascript" || mimeType == "application/json" || mimeType == "application/xml" ); }, /** * Returns true if we can show a find bar, including FAYT, for the specified * document location. The location must not be in a blacklist of specific * "about:" pages for which find is disabled. * * This can be called from the parent process or from content processes. */ canFindInPage(location) { return ( !location.startsWith("about:addons") && !location.startsWith( "chrome://mozapps/content/extensions/aboutaddons.html" ) && !location.startsWith("about:preferences") ); }, _visibleToolbarsMap: new WeakMap(), /** * Return true if any or a specific toolbar that interacts with the content * document is visible. * * @param {nsIDocShell} docShell The docShell instance that a toolbar should * be interacting with * @param {String} which Identifier of a specific toolbar * @return {Boolean} */ isToolbarVisible(docShell, which) { let window = this.getRootWindow(docShell); if (!this._visibleToolbarsMap.has(window)) { return false; } let toolbars = this._visibleToolbarsMap.get(window); return !!toolbars && toolbars.has(which); }, /** * Sets the --toolbarbutton-button-height CSS property on the closest * toolbar to the provided element. Useful if you need to vertically * center a position:absolute element within a toolbar that uses * -moz-pack-align:stretch, and thus a height which is dependant on * the font-size. * * @param element An element within the toolbar whose height is desired. */ async setToolbarButtonHeightProperty(element) { let window = element.ownerGlobal; let dwu = window.windowUtils; let toolbarItem = element; let urlBarContainer = element.closest("#urlbar-container"); if (urlBarContainer) { // The stop-reload-button, which is contained in #urlbar-container, // needs to use #urlbar-container to calculate the bounds. toolbarItem = urlBarContainer; } if (!toolbarItem) { return; } let bounds = dwu.getBoundsWithoutFlushing(toolbarItem); if (!bounds.height) { await window.promiseDocumentFlushed(() => { bounds = dwu.getBoundsWithoutFlushing(toolbarItem); }); } if (bounds.height) { toolbarItem.style.setProperty( "--toolbarbutton-height", bounds.height + "px" ); } }, /** * Track whether a toolbar is visible for a given a docShell. * * @param {nsIDocShell} docShell The docShell instance that a toolbar should * be interacting with * @param {String} which Identifier of a specific toolbar * @param {Boolean} [visible] Whether the toolbar is visible. Optional, * defaults to `true`. */ trackToolbarVisibility(docShell, which, visible = true) { // We have to get the root window object, because XPConnect WrappedNatives // can't be used as WeakMap keys. let window = this.getRootWindow(docShell); let toolbars = this._visibleToolbarsMap.get(window); if (!toolbars) { toolbars = new Set(); this._visibleToolbarsMap.set(window, toolbars); } if (!visible) { toolbars.delete(which); } else { toolbars.add(which); } }, /** * Retrieve the root window object (i.e. the top-most content global) for a * specific docShell object. * * @param {nsIDocShell} docShell * @return {nsIDOMWindow} */ getRootWindow(docShell) { return docShell.browsingContext.top.window; }, /** * Trim the selection text to a reasonable size and sanitize it to make it * safe for search query input. * * @param aSelection * The selection text to trim. * @param aMaxLen * The maximum string length, defaults to a reasonable size if undefined. * @return The trimmed selection text. */ trimSelection(aSelection, aMaxLen) { // Selections of more than 150 characters aren't useful. const maxLen = Math.min(aMaxLen || 150, aSelection.length); if (aSelection.length > maxLen) { // only use the first maxLen important chars. see bug 221361 let pattern = new RegExp("^(?:\\s*.){0," + maxLen + "}"); pattern.test(aSelection); aSelection = RegExp.lastMatch; } aSelection = aSelection.trim().replace(/\s+/g, " "); if (aSelection.length > maxLen) { aSelection = aSelection.substr(0, maxLen); } return aSelection; }, /** * Retrieve the text selection details for the given window. * * @param aTopWindow * The top window of the element containing the selection. * @param aCharLen * The maximum string length for the selection text. * @return The selection details containing the full and trimmed selection text * and link details for link selections. */ getSelectionDetails(aTopWindow, aCharLen) { let focusedWindow = {}; let focusedElement = Services.focus.getFocusedElementForWindow( aTopWindow, true, focusedWindow ); focusedWindow = focusedWindow.value; let selection = focusedWindow.getSelection(); let selectionStr = selection.toString(); let fullText; let url; let linkText; let isDocumentLevelSelection = true; // try getting a selected text in text input. if (!selectionStr && focusedElement) { // Don't get the selection for password fields. See bug 565717. if ( ChromeUtils.getClassName(focusedElement) === "HTMLTextAreaElement" || (ChromeUtils.getClassName(focusedElement) === "HTMLInputElement" && focusedElement.mozIsTextField(true)) ) { selection = focusedElement.editor.selection; selectionStr = selection.toString(); isDocumentLevelSelection = false; } } let collapsed = selection.isCollapsed; if (selectionStr) { // Have some text, let's figure out if it looks like a URL that isn't // actually a link. linkText = selectionStr.trim(); if (/^(?:https?|ftp):/i.test(linkText)) { try { url = this.makeURI(linkText); } catch (ex) {} } else if (/^(?:[a-z\d-]+\.)+[a-z]+$/i.test(linkText)) { // Check if this could be a valid url, just missing the protocol. // Now let's see if this is an intentional link selection. Our guess is // based on whether the selection begins/ends with whitespace or is // preceded/followed by a non-word character. // selection.toString() trims trailing whitespace, so we look for // that explicitly in the first and last ranges. let beginRange = selection.getRangeAt(0); let delimitedAtStart = /^\s/.test(beginRange); if (!delimitedAtStart) { let container = beginRange.startContainer; let offset = beginRange.startOffset; if (container.nodeType == container.TEXT_NODE && offset > 0) { delimitedAtStart = /\W/.test(container.textContent[offset - 1]); } else { delimitedAtStart = true; } } let delimitedAtEnd = false; if (delimitedAtStart) { let endRange = selection.getRangeAt(selection.rangeCount - 1); delimitedAtEnd = /\s$/.test(endRange); if (!delimitedAtEnd) { let container = endRange.endContainer; let offset = endRange.endOffset; if ( container.nodeType == container.TEXT_NODE && offset < container.textContent.length ) { delimitedAtEnd = /\W/.test(container.textContent[offset]); } else { delimitedAtEnd = true; } } } if (delimitedAtStart && delimitedAtEnd) { try { url = Services.uriFixup.getFixupURIInfo(linkText).preferredURI; } catch (ex) {} } } } if (selectionStr) { // Pass up to 16K through unmolested. If an add-on needs more, they will // have to use a content script. fullText = selectionStr.substr(0, 16384); selectionStr = this.trimSelection(selectionStr, aCharLen); } if (url && !url.host) { url = null; } return { text: selectionStr, docSelectionIsCollapsed: collapsed, isDocumentLevelSelection, fullText, linkURL: url ? url.spec : null, linkText: url ? linkText : "", }; }, /** * Replaces %s or %S in the provided url or postData with the given parameter, * acccording to the best charset for the given url. * * @return [url, postData] * @throws if nor url nor postData accept a param, but a param was provided. */ async parseUrlAndPostData(url, postData, param) { let hasGETParam = /%s/i.test(url); let decodedPostData = postData ? unescape(postData) : ""; let hasPOSTParam = /%s/i.test(decodedPostData); if (!hasGETParam && !hasPOSTParam) { if (param) { // If nor the url, nor postData contain parameters, but a parameter was // provided, return the original input. throw new Error( "A param was provided but there's nothing to bind it to" ); } return [url, postData]; } let charset = ""; const re = /^(.*)\&mozcharset=([a-zA-Z][_\-a-zA-Z0-9]+)\s*$/; let matches = url.match(re); if (matches) { [, url, charset] = matches; } else { // Try to fetch a charset from History. try { // Will return an empty string if character-set is not found. let pageInfo = await PlacesUtils.history.fetch(url, { includeAnnotations: true, }); if (pageInfo && pageInfo.annotations.has(PlacesUtils.CHARSET_ANNO)) { charset = pageInfo.annotations.get(PlacesUtils.CHARSET_ANNO); } } catch (ex) { // makeURI() throws if url is invalid. Cu.reportError(ex); } } // encodeURIComponent produces UTF-8, and cannot be used for other charsets. // escape() works in those cases, but it doesn't uri-encode +, @, and /. // Therefore we need to manually replace these ASCII characters by their // encodeURIComponent result, to match the behavior of nsEscape() with // url_XPAlphas. let encodedParam = ""; if (charset && charset != "UTF-8") { try { let converter = Cc[ "@mozilla.org/intl/scriptableunicodeconverter" ].createInstance(Ci.nsIScriptableUnicodeConverter); converter.charset = charset; encodedParam = converter.ConvertFromUnicode(param) + converter.Finish(); } catch (ex) { encodedParam = param; } encodedParam = escape(encodedParam).replace( /[+@\/]+/g, encodeURIComponent ); } else { // Default charset is UTF-8 encodedParam = encodeURIComponent(param); } url = url.replace(/%s/g, encodedParam).replace(/%S/g, param); if (hasPOSTParam) { postData = decodedPostData .replace(/%s/g, encodedParam) .replace(/%S/g, param); } return [url, postData]; }, /** * Generate a document fragment for a localized string that has DOM * node replacements. This avoids using getFormattedString followed * by assigning to innerHTML. Fluent can probably replace this when * it is in use everywhere. * * @param {Document} doc * @param {String} msg * The string to put replacements in. Fetch from * a stringbundle using getString or GetStringFromName, * or even an inserted dtd string. * @param {Node|String} nodesOrStrings * The replacement items. Can be a mix of Nodes * and Strings. However, for correct behaviour, the * number of items provided needs to exactly match * the number of replacement strings in the l10n string. * @returns {DocumentFragment} * A document fragment. In the trivial case (no * replacements), this will simply be a fragment with 1 * child, a text node containing the localized string. */ getLocalizedFragment(doc, msg, ...nodesOrStrings) { // Ensure replacement points are indexed: for (let i = 1; i <= nodesOrStrings.length; i++) { if (!msg.includes("%" + i + "$S")) { msg = msg.replace(/%S/, "%" + i + "$S"); } } let numberOfInsertionPoints = msg.match(/%\d+\$S/g).length; if (numberOfInsertionPoints != nodesOrStrings.length) { Cu.reportError( `Message has ${numberOfInsertionPoints} insertion points, ` + `but got ${nodesOrStrings.length} replacement parameters!` ); } let fragment = doc.createDocumentFragment(); let parts = [msg]; let insertionPoint = 1; for (let replacement of nodesOrStrings) { let insertionString = "%" + insertionPoint++ + "$S"; let partIndex = parts.findIndex( part => typeof part == "string" && part.includes(insertionString) ); if (partIndex == -1) { fragment.appendChild(doc.createTextNode(msg)); return fragment; } if (typeof replacement == "string") { parts[partIndex] = parts[partIndex].replace( insertionString, replacement ); } else { let [firstBit, lastBit] = parts[partIndex].split(insertionString); parts.splice(partIndex, 1, firstBit, replacement, lastBit); } } // Put everything in a document fragment: for (let part of parts) { if (typeof part == "string") { if (part) { fragment.appendChild(doc.createTextNode(part)); } } else { fragment.appendChild(part); } } return fragment; }, /** * Returns a Promise which resolves when the given observer topic has been * observed. * * @param {string} topic * The topic to observe. * @param {function(nsISupports, string)} [test] * An optional test function which, when called with the * observer's subject and data, should return true if this is the * expected notification, false otherwise. * @returns {Promise<object>} */ promiseObserved(topic, test = () => true) { return new Promise(resolve => { let observer = (subject, topic, data) => { if (test(subject, data)) { Services.obs.removeObserver(observer, topic); resolve({ subject, data }); } }; Services.obs.addObserver(observer, topic); }); }, removeSingleTrailingSlashFromURL(aURL) { // remove single trailing slash for http/https/ftp URLs return aURL.replace(/^((?:http|https|ftp):\/\/[^/]+)\/$/, "$1"); }, /** * Returns a URL which has been trimmed by removing 'http://' and any * trailing slash (in http/https/ftp urls). * Note that a trimmed url may not load the same page as the original url, so * before loading it, it must be passed through URIFixup, to check trimming * doesn't change its destination. We don't run the URIFixup check here, * because trimURL is in the page load path (see onLocationChange), so it * must be fast and simple. * * @param {string} aURL The URL to trim. * @returns {string} The trimmed string. */ get trimURLProtocol() { return "http://"; }, trimURL(aURL) { let url = this.removeSingleTrailingSlashFromURL(aURL); // Remove "http://" prefix. return url.startsWith(this.trimURLProtocol) ? url.substring(this.trimURLProtocol.length) : url; }, recordSiteOriginTelemetry(aWindows, aIsGeckoView) { Services.tm.idleDispatchToMainThread(() => { this._recordSiteOriginTelemetry(aWindows, aIsGeckoView); }); }, computeSiteOriginCount(aWindows, aIsGeckoView) { // Geckoview and Desktop work differently. On desktop, aBrowser objects // holds an array of tabs which we can use to get the <browser> objects. // In Geckoview, it is apps' responsibility to keep track of the tabs, so // there isn't an easy way for us to get the tabs. let tabs = []; if (aIsGeckoView) { // To get all active windows; Each tab has its own window tabs = aWindows; } else { for (const win of aWindows) { tabs = tabs.concat(win.gBrowser.tabs); } } let topLevelBCs = []; for (const tab of tabs) { let browser; if (aIsGeckoView) { browser = tab.browser; } else { browser = tab.linkedBrowser; } if (browser.browsingContext) { // This is the top level browsingContext topLevelBCs.push(browser.browsingContext); } } return CanonicalBrowsingContext.countSiteOrigins(topLevelBCs); }, _recordSiteOriginTelemetry(aWindows, aIsGeckoView) { let currentTime = Date.now(); // default is 5 minutes if (!this.min_interval) { this.min_interval = Services.prefs.getIntPref( "telemetry.number_of_site_origin.min_interval", 300000 ); } let originCount = this.computeSiteOriginCount(aWindows, aIsGeckoView); let histogram = Services.telemetry.getHistogramById( "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_ALL_TABS" ); // Discard the first load because most of the time the first load only has 1 // tab and 1 window open, so it is useless to report it. if (!this._lastRecordSiteOrigin) { this._lastRecordSiteOrigin = currentTime; } else if (currentTime >= this._lastRecordSiteOrigin + this.min_interval) { this._lastRecordSiteOrigin = currentTime; histogram.add(originCount); } // Update the Fission experiment qualification state based on the // current origin count: // If we don't already have a last disqualification timestamp, look // through the existing histogram values, and use the existing // maximum value as the initial count. This will prevent us from // enrolling users in the experiment if they have a history of // exceeding our origin cap. if (!this._checkedInitialExperimentQualification) { this._checkedInitialExperimentQualification = true; if ( !Services.prefs.prefHasUserValue( FISSION_EXPERIMENT_PREF_LAST_DISQUALIFIED ) ) { for (let [bucketStr, entryCount] of Object.entries( histogram.snapshot().values )) { let bucket = Number(bucketStr); if (bucket > originCount && entryCount > 0) { originCount = bucket; } } Services.prefs.setIntPref(FISSION_EXPERIMENT_PREF_LAST_DISQUALIFIED, 0); } } let currentTimeSec = currentTime / 1000; if (originCount < fissionExperimentMaxOrigins) { let lastDisqualified = fissionExperimentLastDisqualified; let lastQualified = fissionExperimentLastQualified; // If the last time we saw a qualifying origin count was earlier // than the last time we say a disqualifying count, update any // existing last disqualified timestamp to just before now, on the // basis that our origin count has probably just fallen below the // cap. if (lastDisqualified > 0 && lastQualified <= lastDisqualified) { Services.prefs.setIntPref( FISSION_EXPERIMENT_PREF_LAST_DISQUALIFIED, currentTimeSec - 1 ); } if (!fissionExperimentQualified) { Services.prefs.setIntPref( FISSION_EXPERIMENT_PREF_LAST_QUALIFIED, currentTimeSec ); // We have a qualifying origin count now. If the last time we were // disqualified was prior to the start of our current sliding // window, re-qualify the user. if ( currentTimeSec - lastDisqualified >= fissionExperimentSlidingWindowMS / 1000 ) { Services.prefs.setBoolPref(FISSION_EXPERIMENT_PREF_QUALIFIED, true); } } } else { Services.prefs.setIntPref( FISSION_EXPERIMENT_PREF_LAST_DISQUALIFIED, currentTimeSec ); Services.prefs.setBoolPref(FISSION_EXPERIMENT_PREF_QUALIFIED, false); } }, /** * Converts a property bag to object. * @param {nsIPropertyBag} bag - The property bag to convert * @returns {Object} - The object representation of the nsIPropertyBag */ propBagToObject(bag) { function toValue(property) { if (typeof property != "object") { return property; } if (Array.isArray(property)) { return property.map(this.toValue, this); } if (property && property instanceof Ci.nsIPropertyBag) { return this.propBagToObject(property); } return property; } if (!(bag instanceof Ci.nsIPropertyBag)) { throw new TypeError("Not a property bag"); } let result = {}; for (let { name, value: property } of bag.enumerator) { let value = toValue(property); result[name] = value; } return result; }, /** * Converts an object to a property bag. * @param {Object} obj - The object to convert. * @returns {nsIPropertyBag} - The property bag representation of the object. */ objectToPropBag(obj) { function fromValue(value) { if (typeof value == "function") { return null; // Emulating the behavior of JSON.stringify with functions } if (Array.isArray(value)) { return value.map(this.fromValue, this); } if (value == null || typeof value != "object") { // Auto-converted to nsIVariant return value; } return this.objectToPropBag(value); } if (obj == null || typeof obj != "object") { throw new TypeError("Invalid object: " + obj); } let bag = Cc["@mozilla.org/hash-property-bag;1"].createInstance( Ci.nsIWritablePropertyBag ); for (let k of Object.keys(obj)) { let value = fromValue(obj[k]); bag.setProperty(k, value); } return bag; }, }; XPCOMUtils.defineLazyPreferenceGetter( BrowserUtils, "navigationRequireUserInteraction", "browser.navigation.requireUserInteraction", false );
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%3E%u0423%u0432%u0435%u043B%u0438%u0447%u0438%u0442%u044C%20%u0418%u0437%u043E%u0431%u0440%u0430%u0436%u0435%u043D%u0438%u0435%3C/name%3E%0A%20%20%3Cimage%3E%3C%21%5BCDATA%5Bdata%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADZElEQVR42oXSe0xbVRwH8N8597a35e7SAmUFukGhY66AMiNzw4GvTCQLCssc4pQsmTOa+ERMlrktW1zigpnEuWn8x2eMmiVGMBDCFjS+cJHEDIk8RoSNV1+3tLWX3t72nnO8sETJFrfvP7/k5Pw+Ob9fDoLrYi8ow9GFUbq+5aRLrGraqQcX6hlF2wkFEWn6EDIJAyQy9+3VT58cWb6PrmvmjGZS/FSHlxbXtbtLobGqJlPKMhNepWb0V8hKpi8FNd/gzCCogbdmvtg/8C9gz9+Eor5x5nn2tDOZ98Dx2i3C/uYai9mOGCxiDQIIg1/PgUCEhyvDMox9PXYBkPzaaoAzAFL0yle7ShtqO/eWJ9w1vJ1oGsVzYhTNATMQG4Q1G40ldDw6PB339fs7VgMmA0jnHfioo6F9Z3tDYYJzKSZKMYcDvAILiICfZUNYEYFixMKpKBk8MfTTasBsACnngU/6Wg4+VL/VFSOmBHAYY1BAhzAvgmyMEIkh0EUOBD1Eu49eStwA5D3z4TcPv9TYdHvxEhXSGgaEIMkJkKAS+ONmSKYolOVqMBlRSd8bv8v/AQXlJoiHUE5rZ1tFa/Nhj1uVrCaNMoQxYSaIqDxAGqAuQ2XZ1iS8HUTpkZMXe1eATOdtiCcJblGe1a3PnWp0uEvfv3tbeX5RhSet/q3wxh6xgAncZUmw2hxEryQx9/LHE7I2RV5HNudGFAtcZsuQd919u/kiz56JOwobcjd6xerqKnB4HIB4RvMzCM1DGj8X0GD64pL2Xdf850z+4djKC8wl24XUpj1P75sdfe/+sSHoq3uQnSuwa+s2Vy5uubd2jQWUTAYchJK8HpyIzvv7p/rMkV/OzPeeGEWi+x6LufiR573h8VO7Zr4n9fEZNeiqXHOofFvPsKPkS1fKsX5JU6uNZQh8Wh/hRcuvOC3/fLXrcGj52yOo7zzU9udvbzbN9uglggK2MhsnvfiE0tY9tfed7vM98D+x53tx1DdG0Z2b97Ejf3SRSiGGCysyENvdoipZa4+/8NmPp8+N+Ei2ZEVpQhG71rdcqFFozD+xcoQugFUvlDS8wWsl8Uebk5C79ujjHwyc6R/309ysDBRauEzhJkG9ErAdG0xEe6yVkwqcr+549/zZgcmQ7pAEkH2TDG6RfwCoJI0uEWJP5QAAAABJRU5ErkJggg%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/*Initialization%20Code*/%0AaddEventListener%28%22popupshowing%22%2C%20%7B%0A%20%20%20%20imgZoom%3A%20190%2C%20%20%20//%20%u043D%u0430%20%u0441%u043A%u043E%u043B%u044C%u043A%u043E%20%u0443%u0432%u0435%u043B%u0438%u0447%u0438%u0442%u044C%20%u0438%u0437%u043E%u0431%u0440%u0430%u0436%u0435%u043D%u0438%u0435%20%u0438%u0437%20%u043C%u0435%u043D%u044E%0A%20%20%20%20scrollZoom%3A%2020%2C%20//%20%u043D%u0430%20%u0441%u043A%u043E%u043B%u044C%u043A%u043E%20%u0443%u0432%u0435%u043B%u0438%u0447%u0438%u0432%u0430%u0442%u044C/%u0443%u043C%u0435%u043D%u044C%u0448%u0430%u0442%u044C%20%u043A%u043E%u043B%u0435%u0441%u0438%u043A%u043E%u043C%20%u043C%u044B%u0448%u0438%0A%20%20%20%20scrollTop%3A%201%2C%20%20%20//%20%u0438%u043B%u0438%20-1%2C%20%u043F%u0435%u0440%u0435%u043A%u043B%u044E%u0447%u0435%u043D%u0438%u0435%20%u043D%u0430%u043F%u0440%u0430%u0432%u043B%u0435%u043D%u0438%u0435%20%u043F%u0440%u043E%u043A%u0440%u0443%u0442%u043A%u0438%20%u0434%u043B%u044F%20%u0443%u0432%u0435%u043B%u0438%u0447%u0435%u043D%u0438%u0435%20%u043A%u043E%u043B%u0451%u0441%u0438%u043A%u043E%u043C%0A%0A%20%20%20%20receiveMessage%28msg%29%20%7B%0A%20%20%20%20%20%20%20%20var%20container%20%3D%20document.documentElement%0A%20%20%20%20%20%20%20%20%20%20%20%20.appendChild%28document.createElement%28%22div%22%29%29%3B%0A%20%20%20%20%20%20%20%20addDestructor%28%28%29%20%3D%3E%20container.remove%28%29%29%3B%0A%20%20%20%20%20%20%20%20var%20image%20%3D%20container.appendChild%28document.createXULElement%28%22image%22%29%29%3B%0A%20%20%20%20%20%20%20%20image.style.cssText%20%3D%20%22width%3A%20100%25%20%21important%3B%20height%3A%20100%25%20%21important%3B%22%3B%0A%20%20%20%20%20%20%20%20image.setAttribute%28%22validate%22%2C%20%22never%22%29%3B%0A%0A%20%20%20%20%20%20%20%20var%20st%20%3D%20container.style%3B%0A%20%20%20%20%20%20%20%20var%20dz%20%3D%20this.scrollZoom/100%20*%20this.scrollTop%3B%0A%20%20%20%20%20%20%20%20var%20currScale%20%3D%201%2C%20x%2C%20y%2C%20initialZoom%20%3D%20this.imgZoom/100%20-%201%3B%0A%0A%20%20%20%20%20%20%20%20var%20hide%2C%20props%20%3D%20%5B%22width%22%2C%20%22height%22%2C%20%22left%22%2C%20%22top%22%5D%2C%20p%20%3D%20n%20%3D%3E%20n%20+%20%22px%22%3B%0A%20%20%20%20%20%20%20%20var%20set%20%3D%20%28...args%29%20%3D%3E%20props.forEach%28%28prop%2C%20ind%29%20%3D%3E%20st%5Bprop%5D%20%3D%20p%28args%5Bind%5D%29%29%3B%0A%0A%20%20%20%20%20%20%20%20%28hide%20%3D%20%28%29%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20st.cssText%20%3D%20%22position%3A%20fixed%3B%20display%3A%20none%3B%20z-index%3A%202147483647%3B%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20currScale%20%3D%201%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20image.src%20%3D%20null%3B%0A%20%20%20%20%20%20%20%20%7D%29%28%29%3B%0A%20%20%20%20%20%20%20%20container.onwheel%20%3D%20%28e%2C%20ds%20%3D%20e.deltaY%20%3E%200%20%3F%20-dz%20%3A%20dz%29%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20%28currScale%20%3C%20.15%20%26%26%20ds%20%3C%200%29%20return%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20st.transform%20%3D%20%60scale%28%24%7BcurrScale%20+%3D%20ds%7D%29%60%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20%7Bwidth%2C%20height%2C%20left%2C%20top%2C%20bottom%2C%20right%7D%20%3D%20container.getBoundingClientRect%28%29%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20%28height%20%3C%20innerHeight%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28top%20%3C%200%29%20st.top%20%3D%20p%28y%20-%3D%20top%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28bottom%20%3E%20innerHeight%29%20st.top%20%3D%20p%28y%20-%3D%20bottom%20-%20innerHeight%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20%28width%20%3C%20innerWidth%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28left%20%3C%200%29%20st.left%20%3D%20p%28x%20-%3D%20left%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28right%20%3E%20innerWidth%29%20st.left%20%3D%20p%28x%20-%3D%20right%20-%20innerWidth%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%28this.receiveMessage%20%3D%20msg%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20%7Bsrc%2C%20width%2C%20height%2C%20left%2C%20top%7D%20%3D%20msg.data%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20image.src%20%3D%20src%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20left%20-%3D%20mozInnerScreenX%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20top%20-%3D%20mozInnerScreenY%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20set%28width%2C%20height%2C%20x%20%3D%20left%2C%20y%20%3D%20top%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20st.display%20%3D%20%22block%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20container.onwheel%28null%2C%20initialZoom%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20window.addEventListener%28%22mousedown%22%2C%20hide%2C%20%7Bonce%3A%20true%2C%20capture%3A%20true%7D%29%3B%0A%20%20%20%20%20%20%20%20%7D%29%28msg%29%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20handleEvent%28e%29%20%7B%0A%20%20%20%20%20%20%20%20if%20%28%21gContextMenu.onImage%29%20return%3B%0A%20%20%20%20%20%20%20%20var%20menuitem%20%3D%20document.createXULElement%28%22menuitem%22%29%3B%0A%20%20%20%20%20%20%20%20menuitem.setAttribute%28%22label%22%2C%20%22%u0423%u0432%u0435%u043B%u0438%u0447%u0438%u0442%u044C%20%u0440%u0430%u0437%u043C%u0435%u0440%22%29%3B%0A%20%20%20%20%20%20%20%20menuitem.className%20%3D%20%22menuitem-iconic%22%3B%0A%20%20%20%20%20%20%20%20menuitem.setAttribute%28%22image%22%2C%20%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADZElEQVR42oXSe0xbVRwH8N8597a35e7SAmUFukGhY66AMiNzw4GvTCQLCssc4pQsmTOa+ERMlrktW1zigpnEuWn8x2eMmiVGMBDCFjS+cJHEDIk8RoSNV1+3tLWX3t72nnO8sETJFrfvP7/k5Pw+Ob9fDoLrYi8ow9GFUbq+5aRLrGraqQcX6hlF2wkFEWn6EDIJAyQy9+3VT58cWb6PrmvmjGZS/FSHlxbXtbtLobGqJlPKMhNepWb0V8hKpi8FNd/gzCCogbdmvtg/8C9gz9+Eor5x5nn2tDOZ98Dx2i3C/uYai9mOGCxiDQIIg1/PgUCEhyvDMox9PXYBkPzaaoAzAFL0yle7ShtqO/eWJ9w1vJ1oGsVzYhTNATMQG4Q1G40ldDw6PB339fs7VgMmA0jnHfioo6F9Z3tDYYJzKSZKMYcDvAILiICfZUNYEYFixMKpKBk8MfTTasBsACnngU/6Wg4+VL/VFSOmBHAYY1BAhzAvgmyMEIkh0EUOBD1Eu49eStwA5D3z4TcPv9TYdHvxEhXSGgaEIMkJkKAS+ONmSKYolOVqMBlRSd8bv8v/AQXlJoiHUE5rZ1tFa/Nhj1uVrCaNMoQxYSaIqDxAGqAuQ2XZ1iS8HUTpkZMXe1eATOdtiCcJblGe1a3PnWp0uEvfv3tbeX5RhSet/q3wxh6xgAncZUmw2hxEryQx9/LHE7I2RV5HNudGFAtcZsuQd919u/kiz56JOwobcjd6xerqKnB4HIB4RvMzCM1DGj8X0GD64pL2Xdf850z+4djKC8wl24XUpj1P75sdfe/+sSHoq3uQnSuwa+s2Vy5uubd2jQWUTAYchJK8HpyIzvv7p/rMkV/OzPeeGEWi+x6LufiR573h8VO7Zr4n9fEZNeiqXHOofFvPsKPkS1fKsX5JU6uNZQh8Wh/hRcuvOC3/fLXrcGj52yOo7zzU9udvbzbN9uglggK2MhsnvfiE0tY9tfed7vM98D+x53tx1DdG0Z2b97Ejf3SRSiGGCysyENvdoipZa4+/8NmPp8+N+Ei2ZEVpQhG71rdcqFFozD+xcoQugFUvlDS8wWsl8Uebk5C79ujjHwyc6R/309ysDBRauEzhJkG9ErAdG0xEe6yVkwqcr+549/zZgcmQ7pAEkH2TDG6RfwCoJI0uEWJP5QAAAABJRU5ErkJggg%3D%3D%22%29%3B%0A%20%20%20%20%20%20%20%20menuitem.setAttribute%28%22oncommand%22%2C%20%22handleCommand%28%29%3B%22%29%3B%0A%20%20%20%20%20%20%20%20e.target.append%28menuitem%29%3B%0A%20%20%20%20%20%20%20%20addDestructor%28%28%29%20%3D%3E%20menuitem.remove%28%29%29%3B%0A%20%20%20%20%20%20%20%20menuitem.handleCommand%20%3D%20%28%29%20%3D%3E%20this.cmd%28%29%3B%0A%0A%20%20%20%20%20%20%20%20this.handleEvent%20%3D%20%28%29%20%3D%3E%20menuitem.hidden%20%3D%20%21gContextMenu.onImage%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20cmd%28%29%20%7B%0A%20%20%20%20%20%20%20%20var%20msg%20%3D%20%22CB%3AGetImageScreenRectForMosuseZoom%22%3B%0A%20%20%20%20%20%20%20%20var%20code%20%3D%20%60%28targetIdentifier%20%3D%3E%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20image%20%3D%20ChromeUtils.import%28%22resource%3A//gre/modules/ContentDOMReference.jsm%22%29%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.ContentDOMReference.resolve%28targetIdentifier%29%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20mm%20%3D%20image.ownerGlobal.docShell.messageManager%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20bu%20%3D%20mm.BrowserUtils%20%7C%7C%20ChromeUtils%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.import%28%22resource%3A//gre/modules/BrowserUtils.jsm%22%29.BrowserUtils%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20mm.sendAsyncMessage%28%22%24%7Bmsg%7D%22%2C%20Object.assign%28%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bsrc%3A%20image.currentSrc%7D%2C%20bu.getElementBoundingScreenRect%28image%29%0A%20%20%20%20%20%20%20%20%20%20%20%20%29%29%3B%0A%20%20%20%20%20%20%20%20%7D%29%28%60%3B%0A%20%20%20%20%20%20%20%20messageManager.addMessageListener%28msg%2C%20this%29%3B%0A%20%20%20%20%20%20%20%20addDestructor%28%28%29%20%3D%3E%20messageManager.removeMessageListener%28msg%2C%20this%29%29%3B%0A%0A%20%20%20%20%20%20%20%20%28this.cmd%20%3D%20%28%29%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20%7BosPid%7D%20%3D%20gContextMenu.actor.manager.browsingContext.currentWindowGlobal%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20%28osPid%20%3D%3D%20-1%29%20osPid%20%3D%20Services.appinfo.processID%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20for%28var%20ind%20%3D%200%2C%20len%20%3D%20Services.ppmm.childCount%3B%20ind%20%3C%20len%3B%20ind++%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20pmm%20%3D%20Services.ppmm.getChildAt%28ind%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28pmm.osPid%20%3D%3D%20osPid%29%20break%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20pmm.loadProcessScript%28%22data%3A%3Bcharset%3Dutf-8%2C%22%20+%20encodeURIComponent%28%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20code%20+%20JSON.stringify%28gContextMenu.targetIdentifier%29%20+%20%22%29%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%29%2C%20false%29%3B%0A%20%20%20%20%20%20%20%20%7D%29%28%29%3B%0A%20%20%20%20%7D%0A%7D%2C%20false%2C%20document.getElementById%28%22contentAreaContextMenu%22%29%20%7C%7C%201%29%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
Отредактировано ВВП (25-08-2021 14:27:53)
Отсутствует
unter_officer
застрял на перетаскивании вкладок
Во, вроде получилось. Как бы со всего этого глюки не пошли.
Код для ucf custom_script_win.js, в конец, не в «по событию "load" не раньше».
(async proto => { // MozTabbrowserTab.prototype.pinned getter var skipList = [ "on_dragstart@chrome://browser/content/tabbrowser-tabs.js", "on_drop@chrome://browser/content/tabbrowser-tabs.js", "_setPositionalAttributes@chrome://browser/content/tabbrowser-tabs.js", "_numPinnedTabs@chrome://browser/content/tabbrowser.js", "moveTabTo@chrome://browser/content/tabbrowser.js", ]; var includes = function(str) { return this.includes(str); } Object.defineProperty(proto, "pinned", { configurable: true, enumerable: true, get() { return this.getAttribute("pinned") == "true" && !skipList.some(includes, Components.stack.formattedStack); } }); var count = 1e5; while(!window.gBrowser && --count) await Promise.resolve(); // gBrowser.addMultipleTabs() var key = "restorePinnedTabPos"; Object.assign(gBrowser, eval( `({${gBrowser.addMultipleTabs}})`.replace( "tab.initialize();", `$&\n this.${key}(aPropertiesTabs.length, i, tabData.pinned, tab);` ) )); var prevTab, pinnedTabs = new Map(); var moveTabs = () => { for(var [tab, pinSibling] of pinnedTabs) tab.isConnected && !tab.closing && gBrowser.moveTabTo(tab, pinSibling._tPos); pinnedTabs.clear(); } gBrowser[key] = (len, ind, pinned, tab) => { ind && pinned && pinnedTabs.set(tab, prevTab); if (ind + 1 < len) return prevTab = tab; prevTab = null; if (pinnedTabs.size) window.addEventListener("SSWindowRestored", moveTabs, {once: true}), setTimeout(() => pinnedTabs.size && window.removeEventListener("SSWindowRestored", moveTabs) , 200); } // gBrowser.(un)pinTab() for(var prop of ["pinTab", "unpinTab"]) Object.assign(gBrowser, eval( `({${gBrowser[prop]}})`.replace("this.moveTabTo", "//$&") )); // SessionStoreInternal.undoCloseTab(); key = "undoCloseTab"; var flag = key + "DePinPatch"; var nsvo = Cu.import("resource:///modules/sessionstore/SessionStore.jsm", {}); if (!nsvo[flag]) { nsvo[flag] = true; var ssi = nsvo.SessionStoreInternal; ssi[key] = Cu.getGlobalForObject(Cu).eval(`(${ssi[key]})`.replace( "}));", "$&\n state.pinned && tabbrowser.moveTabTo(tab, pos);" )); } // MozTabbrowserTabs.prototype._animateTabMove() var tabsProto = customElements.get("tabbrowser-tabs").prototype; key = "reduceTabsForShiftWidth"; tabsProto[key] = (prev, curr) => prev + curr.getBoundingClientRect().width + parseInt(windowUtils.getVisitedDependentComputedStyle(curr, "", "margin-left")) + parseInt(windowUtils.getVisitedDependentComputedStyle(curr, "", "margin-right")); Object.assign(tabsProto, eval( `({${tabsProto._animateTabMove}})` .replace( /let pinned.+?\);/s, "let tabs = this._getVisibleTabs();" ) .replace( /if \(!pinned\) \{(.+?)}/s, "$1" ) .replace( "+ tabWidth);", "+ movingTabs.at(-1).getBoundingClientRect().width);" ) .replace( "tabWidth * movingTabs.length", `movingTabs.reduce(this.${key}, 0)` ) .replace( " + tabWidth / 2", "" ) .replace( " + tabWidth / 2", " + movingTabs.at(-1).getBoundingClientRect().width" ) .replace( "tabs[mid].screenX +", "$& (ltrMove ? 1 : -1) * tabs[mid].getBoundingClientRect().width / 2 +" ) .replace( "newIndex = tabs[mid]._tPos;", "$&\n if (newIndex + +ltrMove == oldIndex) return;" ) )); })(customElements.get("tabbrowser-tab")?.prototype);
не могу понять куда вставить этот код
Код init() заканчивается строкой, содержащей
(this.saveGens = () => Services.prefs.setStringPref(cpref, Array.from(this.gens).join(",")))();
Вот после неё.
Дв.клик по пустоте
Не знаю что сказать. У меня клики по пустоте
не приводят ни к чему необычному.
Отсутствует
Dumby
Не знаю что сказать. У меня клики по пустоте
не приводят ни к чему необычному.
Один клик и именно где кнопки в аддонах. Могу поспорить - это косяк самой "CB" Cам main у меня растянут , а это сжато , если кликнуть как на скрине , то addons://discover/ вылезет
Сжато так:
Отсутствует
Dumby
Во, вроде получилось. Как бы со всего этого глюки не пошли
Вау, я глазам своим не верю! Можно сказать, разрушение законов, правил современного браузеростроения ) Удар по.. мильпардон, ниже пояса Большому Брату
Отсутствует
Cам main у меня растянут , а это сжато
Это, видимо, предлагалось угадать .
Но да, теперь вижу. Добавил такое, и discover не вылезает.
addon-card[addon-id^="custombutton://buttons/"] { pointer-events: none !important; } addon-card[addon-id^="custombutton://buttons/"] * { pointer-events: auto !important; }
Отсутствует
Во, вроде получилось. Как бы со всего этого глюки не пошли.
Dumby, огромное спасибо! То, что надо.
P.S. Кстати. Подобная просьба уже появлялась на форуме в апреле 2013-го. Но тогда за решение этой задачи никто не взялся.
«The Truth Is Out There»
Отсутствует
alur
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAABJ0AAASdAHeZh94AAAAB3RJTUUH4AMCChAIfrcczAAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAAB1klEQVQ4jaWTP2tUQRTFf/e+IaIgRCEg0TLdggoWCsnbV4iF5eYriIVg/IdY7VZbKhILv4PVro2NwSJutLJJsZ1WkohkEbVIFHbmWDhv2dV0GbjcmTt37sw5c65J4igjHBY0s0VgBTibQzvAQNKXf3M9H1gOIVwBKIpiDVgHSmAeOJ3n62a21ul0bOYySZjZI+Ckux+klM4Dz4BtSfv5ghPABeB+fs1DSRGAzMFN4DPwFAiSqK3dbls9BxaAvjt361jNQQGcA44Bt0II2+Px+O3q6qoDNJtNr6oqSdoLITyJMT4wsxeSvnousOHua8And5+PMdLpdKzf72s0GtlgMNBwODSAGOMH4DtwfQLhMAO81Wr5lLcajpldBcoJBDMrzWwupfQmr60sS2s0Gmk0Gnmj0Ui9Xm8imDpvWgdLklbMbEvS77IsvaqqtLm56VVVpW63K7PQdFcT2E8p/QJeS/pYc/Aq//klgBrzNHazZJB+ppSWgOfAtRkOgDvAS2DhsC/MOSFrZAe4IemvkDJuzzpYzH5b0kHeO14UxcUY4z1gCMwBPyQ9nhSoyXPndkosA3vAt7x1CjgDvJe0bmaXs+DezRSYKlQ302IO7QJbknb/yz1qO/8B30AQVyWwBXEAAAAASUVORK5CYII=
Отредактировано vitalii201 (25-08-2021 21:14:11)
Отсутствует
Долго искал по форуму дополнение где качнуть, нашел, продублирую.
Дополнение cusstom_button 0.0.7.0.0.19+ инструкция по установке.
Работает на новой версии 91.0.2 (64-битный),
Отредактировано alur (26-08-2021 18:28:40)
Отсутствует
alur
Не совсем верная инструкция: config.js лучше использовать этот и CB есть более свежая версия 0.0.7.0.0.18
Отредактировано kokoss (26-08-2021 16:32:14)
Win7
Отсутствует
alur
и CB есть более свежая версия 0.0.7.0.0.18
Есть ещё свежее версия.
0.0.7.0.0.19: https://forum.mozilla-russia.org/viewto … 88#p793488
«The Truth Is Out There»
Отсутствует
Dumby,
Слетел url2title для TST последней версии 3.8.12
Скриншот работает
TreeStyleTabPreviewPopup.jsm
var timeout = 100; if (!ChromeUtils.domProcessChild.childID) { var popupWidth = 1000; //big one var label = "ucf_tst_preview_popup"; var tooltiptext = "Some Tooltip Text"; var imgEnabled = "chrome://browser/skin/preferences/face-smile.svg"; var imgDisabled = "chrome://browser/skin/preferences/face-sad.svg"; var btnImage, popupPosition, enabled, addonUUID, registeredUUID; var mo = (p, r = "gre") => ChromeUtils.import(`resource://${r}/modules/${p}.jsm`)[p]; //-------[ Addon ]------------------------------------------------------ var addonId = "treestyletab@piro.sakura.ne.jp"; var manager = mo("ExtensionParent").apiManager; var tt = manager.global.tabTracker; var waitAddon = (e, isAppShutdown) => isAppShutdown || ( addonUUID = null, manager.on("ready", onReady) ); var onReady = (e, addon) => { if (addon.id != addonId) return; manager.off("ready", onReady); addon.once("shutdown", waitAddon); addonUUID = addon.uuid; checkRegistration(); } waitAddon(); //-------[ Actor registration ]------------------------------------------------------ var name = "TreeStyleTabPreviewPopup"; var reg = () => ChromeUtils.registerWindowActor(name, { parent: {moduleURI: __URI__}, messageManagerGroups: ["webext-browsers"], //dezhnev - Url2Title (DOMDocElementInserted) child: {moduleURI: __URI__, events: {DOMDocElementInserted: {}, mouseover: {}}}, matches: [`moz-extension://${registeredUUID = addonUUID}/sidebar/sidebar.html*`] }); var unreg = () => { registeredUUID = null; ChromeUtils.unregisterWindowActor(name); } var checkRegistration = () => { if (enabled) { if (registeredUUID) { if (registeredUUID == addonUUID) return; addonUUID && unreg(); } addonUUID && reg(); } else if (registeredUUID && addonUUID) unreg(); } //------[ Observer ]------------------------------------------------------ var {prefs, obs} = mo("Services"); var pref = "ucf_tst_preview_popup"; var branch = prefs.getBranch("sidebar."); var prefObs = { observe(b, t, data) { this[data]?.(branch.getBoolPref(data, true)); }, position_start: val => popupPosition = val ? "end_before" : "start_before", [pref](val) { btnImage = (enabled = val) ? imgEnabled : imgDisabled; this.setBtnsImg(); checkRegistration(); }, setBtnsImg: () => prefObs.setBtnsImg = () => { var widget = cui.getWidget(btnId); for(var win of cui.windows) widget.forWindow(win).node?.setAttribute("image", btnImage); } }; for (let p of [pref, "position_start"]) prefObs.observe(null, null, p); branch.addObserver("", prefObs); obs.addObserver(function quit(s, topic) { obs.removeObserver(quit, topic); branch.removeObserver("", prefObs); }, "quit-application-granted"); //-------[ Widget ]------------------------------------------------------ var popupId = "ucf-tst-preview-popup"; var btnId = popupId + "-button"; var cui = mo("CustomizableUI", ""); var toggle = () => branch.setBoolPref(pref, !enabled); cui.createWidget({ id: btnId, label, tooltiptext, localized: false, onCreated(btn) { btn.render = this.render; btn._handleClick = toggle; btn.setAttribute("image", btnImage); }, render() { delete this.render; this.render(); this.firstChild.style.setProperty("min-height", "16px", "important"); } }); //-------[ Actor ]------------------------------------------------------ var TreeStyleTabPreviewPopupParent = class extends JSWindowActorParent { actorCreated() { var doc = this.browsingContext.topChromeWindow.document; var popup = doc.getElementById(popupId); if (!popup) { popup = doc.createXULElement("menupopup"); popup.id = popupId; popup.setAttribute("ignorekeys", true); popup.setAttribute("rolluponmousewheel", true); popup.setAttribute("consumeoutsideclicks", "never"); popup.shadowRoot.querySelector("style").append(` :host { padding: 0 !important; -moz-appearance: none !important; } arrowscrollbox::part(scrollbutton-up), arrowscrollbox::part(scrollbutton-down) { display: none !important; } `); (popup.canvas = popup.appendChild(doc.createElement("canvas"))) .width = popupWidth; popup.context = popup.canvas.getContext("2d", {alpha: false}); doc.getElementById("mainPopupSet").append(popup); } this.popup = popup; } receiveMessage(msg) { var id = msg.data; if (!id) return this.popup.hidePopup(); var tab = tt.getTab(+id.slice(4)); if (tab/* && !tab.selected*/) { var cwg = tab.linkedBrowser.browsingContext?.currentWindowGlobal; cwg && this.drawSnapshot(tab.ownerDocument, cwg, id); } } async drawSnapshot(doc, cwg, id) { var {width, height} = await cwg.getActor("Thumbnails") .sendQuery("Browser:Thumbnail:ContentInfo"); if (width < 200) return; var k = popupWidth / width; try {var bitmap = await cwg.drawSnapshot( new DOMRect(0, 0, width, height), k, "white" );} catch {} if (bitmap) { var data = await this.sendQuery(id); if (data) { this.popup.canvas.height = k * height; this.popup.context.drawImage(bitmap, 0, 0); bitmap.close(); this.popup.openPopupAtScreenRect(popupPosition, ...data); } } } didDestroy() { this.popup.hidePopup(); this.popup = null; } } } //Url2Title function updateTextContent() { var span = this.firstElementChild; if (!span) return; var val = this.getAttribute("value"); var url = this.parentNode.dataset.currentUri; if (url?.startsWith("http")) try { var {hostname} = new URL(url); if (hostname) val = `${hostname} | ${val}`; } catch {} span.textContent = val || ""; } class TreeStyleTabPreviewPopupChild extends JSWindowActorChild { actorCreated() { this.args = ["mouseleave", () => { this.tab = null; this.tid || this.sendAsyncMessage(""); this.tid = this.clearTimeout(); }, {once: true}]; } mult(val) { return this * val; } receiveMessage(msg) { var tab = this.document.getElementById(msg.name); var res = tab?.matches(":hover"); if (res) { var {x, y, width, height} = tab.getBoundingClientRect(); var win = tab.ownerGlobal; res = [ x + win.mozInnerScreenX, y + win.mozInnerScreenY, width, height ]; var z = win.windowUtils.screenPixelsPerCSSPixel; if (z != 1) res = res.map(this.mult, z); } return res; } //Url2Title labDefined(lab) { lab.wrappedJSObject.prototype .updateTextContent = updateTextContent; } handleEvent(e) { //Url2Title e.target.ownerGlobal.customElements .whenDefined("tab-label").then(this.labDefined); this.handleEvent = this.mouseover; } mouseover(e) { var tab = e.target.closest("tab-item"); if (!tab || tab == this.tab) return; this.clearTimeout(); this.tid = this.contentWindow .setTimeout(this.onTab, timeout, this.tab = tab, this); tab.addEventListener(...this.args); } clearTimeout() { this.tid && this.contentWindow.clearTimeout(this.tid); } onTab(tab, self) { self.tid = null; tab.wrappedJSObject.apiTab.discarded || self.sendAsyncMessage("", tab.id); } didDestroy() { this.tab = null; } } var EXPORTED_SYMBOLS = ["TreeStyleTabPreviewPopupChild", "TreeStyleTabPreviewPopupParent"];
Отсутствует
dezhnev
....... //var url = this.parentNode.dataset.currentUri; var url = this.closest("tab-item").dataset.currentUri;
Отсутствует