Есть ли способ открывать определённый ключ about:config ? Например: about:config#network.proxy.autoconfig_url ? Если нет, то
как из JS-кода отправить в строку ввода "Искать параметр по имени" название нужного параметра ?
Services.wm.getMostRecentWindow("navigator:browser").switchToTabHavingURI("about:config", true, {relatedToCurrent: true, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()});
Отредактировано Dobrov (07-11-2021 07:38:44)
Отсутствует
Dobrov
Warning, надеюсь, отключён
var filter = "network.proxy.autoconfig_url"; var win = Services.wm.getMostRecentWindow("navigator:browser"); var found = win.switchToTabHavingURI("about:config", true, { relatedToCurrent: true, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal() }); var setFilter = (e, win) => { var input = (e?.target || win.content.document) .getElementById("about-config-search"); if (e || input.value != filter) input.setUserInput(filter); } win = Services.wm.getMostRecentWindow("navigator:browser"); if (found) setFilter(null, win); else win.gBrowser.selectedBrowser.addEventListener("pageshow", setFilter, {once: true});
Отсутствует
Dumby 1. подскажи пожалуста уже этот код не работает
(async () => { var url = `${ AppConstants.SOURCE_REVISION_URL.replace("rev", "raw-file") }/dom/events/${ {win: "win", linux: "unix", macosx: "mac"}[AppConstants.platform] || "unix" }/ShortcutKeyDefinitions.cpp`; var text = await (await fetch(url)).text(); var commands = text.match(/cmd_[^"]+/g); // alert(commands.join("\n")); var text = commands.join("\n"); var file = Services.dirsvc.get('ProfD', Ci.nsIFile); file.append("TextToEditor.txt"); custombuttonsUtils.writeFile(file.path, text); file.launch(); })();
((id, g, css) => { addDestructor(r => r[5] == "e" && g[id]?.destroy(true)); if (g[id]) return; var btnActions = ["preferences", "toggle-disabled", "remove", "install-update"]; var {Array, Set} = Cu.getGlobalForObject(g); var {obs, focus, wm} = Services, cn = "cb-cloned-buttons-container"; var topics = ["chrome-document-loaded", "quit-application-granted"]; (g[id] = { init() { for(var topic of topics) obs.addObserver(this, topic); this.wins(); }, destroy(wins) { delete g[id]; for(var topic of topics) obs.removeObserver(this, topic); wins && this.wins("destroyDoc"); }, isTarget: doc => doc.documentURI == "about:addons", wins(method = "initDoc") { for(var {document: doc} of new Set(Array.from( g.AddonManagerInternal.addonListeners, Cu.getGlobalForObject ))) doc && this.isTarget(doc) && this[method](doc); }, initDoc(doc) { this.btnActions = btnActions.map(action => `panel-list > panel-item[action="${action}"]`); var url = "cb" + (this.url = "data:text/css;charset=utf-8," + encodeURIComponent(css.replace(/;/g, " !important;")) ); this.type = doc.ownerGlobal.windowUtils.USER_SHEET; (this.initDoc = doc => { doc.addEventListener("unload", this); doc.addEventListener("update", this, true); doc.ownerGlobal.windowUtils.loadSheetUsingURIString(url, this.type); for(var card of doc.getElementsByTagName("addon-card")) this.onCard(card); })(doc); }, destroyDoc(doc) { for(var span of Array.from(doc.getElementsByClassName(cn))) span.remove(); doc.ownerGlobal.windowUtils.removeSheetUsingURIString(this.url, this.type); this.unload(doc); }, observe(doc, topic) { topic[0] == "q" ? this.destroy() : this.isTarget(doc) && this.initDoc(doc); }, handleEvent(e) { this[e.type](e.target); }, unload(doc) { doc.removeEventListener("update", this, true); doc.removeEventListener("unload", this); }, update(card) { card.nodeName == "ADDON-CARD" && this.onCard(card); }, onCard(card, again) { var btnsParent = card.querySelector("addon-options"); if (!btnsParent) return again || card.ownerGlobal .requestAnimationFrame(() => this.onCard(card, true)); var doc = card.ownerDocument; var [span] = card.getElementsByClassName(cn); if (span) span.textContent = ""; else { card.querySelector("button.more-options-button") .before(span = doc.createElement("span")); span.className = cn; } for(var item of this.btnActions.map(this.btns, btnsParent)) if (item) span.append(item), item.shadowRoot.querySelector("button") .classList.add("cb-cloned-button"); }, btns(sel) { var item, doc = this.ownerDocument, card = this.parentNode; if ( sel.includes("toggle-disabled") && card.querySelector('input[action="toggle-disabled"]') ) { var item = doc.createElement("panel-item"); item.setAttribute("action", "toggle-disabled"); doc.l10n.setAttributes(item, `${ card.getAttribute("active") == "true" ? "dis" : "en" }able-addon-button`); } else item = this.querySelector(sel); return item?.cloneNode(true); } }).init(); })("CBAboutAddonsHTMLButtonizer", Cu.import("resource://gre/modules/AddonManager.jsm", {}), ` span.cb-cloned-buttons-container { display: flex; } button.cb-cloned-button { appearance: none; padding: 1px 6px 3px 6px; margin: 0 1px; background-image: none; border: 1px solid var(--in-content-box-border-color); border-radius: 0px; font-size: 13px; font-family: Segoe UI; } button.cb-cloned-button:hover { background-color: gold; } button.cb-cloned-button:after, input[action="toggle-disabled"] { display: none; } `);
Отсутствует
2. Дополнительные кнопки на странице about:addons для аддонов, плагинов, тем, CB
скрытый текст
Win7
Отсутствует
kokoss спасибо
Отсутствует
выходит все , кранты
Ну да, теперь отдаётся нечто другое.
Пишут: «On Windows this will return the Commit Size.».
По значениям выглядит похожим на строки «... MB ── private» на странице about:memory
и на значения в колонке «Private Bytes» в программе Process Explorer.
А "очистка", видимо, на эти показатели не влияет.
Допустим, оставить. Код на замену
(async id => ({ delay: 2e3, xul: ` <hbox id="${id}" value="ram" tooltiptext="ЛКМ: Очистить Память" > <label id="${id += "-label"}"/> </hbox> `, css: ` min-height: 26px !important; height: 26px !important; border-radius: 3px !important; padding: 0px 5px 0px !important; color: #00ffff !important; font-size: 15px !important; margin: 0px 1px 1px 3px !important; font-weight: 400 !important; font-family: segoe ui !important; background: linear-gradient(rgb(72, 85, 108),rgb(20, 25, 34)) !important; `, launch() { var file = Services.dirsvc.get("ProfD", Ci.nsIFile); ["memory", "start.vbs"].forEach(file.append); (this.launch = file.launch)(); }, val: "", name: "UCFMemIndReporter", init(topic, mm) { Services.obs.addObserver(mm = this, topic); Services.obs.addObserver(function quit(s, t) { this.timer?.cancel(); Services.obs.removeObserver(mm, topic); Services.obs.removeObserver(quit, t); }, "quit-application-granted"); }, observe(win) { var df = win.MozXULElement.parseXULToFragment(this.xul); this.click = e => e.button || this.launch(); this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); ChromeUtils.registerProcessActor(this.name, { includeParent: true, child: {moduleURI: "chrome://user_chrome_files/content/custom_scripts/memreporter.jsm"} }); (this.observe = async win => { this.timer.cancel(); await new Promise(win.requestAnimationFrame); var clone = win.document.importNode(df, true); var hbox = clone.firstChild; win.document.getElementById("page-action-buttons").append(clone); hbox.onclick = this.click; hbox.style.cssText = this.css; hbox.firstChild.style.setProperty("margin", "0", "important"); this.notify(); })(win); }, async notify() { var bytes = 0, pids = []; for(var dp of ChromeUtils.getAllDOMProcesses()) try { let [pid, mem] = await dp.getActor(this.name).sendQuery(""); pids.push(pid); bytes += mem; } catch {} var {children} = await ChromeUtils.requestProcInfo(); for(var child of children) if (!pids.includes(child.pid)) bytes += child.memory; this.timer.initWithCallback(this, this.delay, this.timer.TYPE_ONE_SHOT); var prev = this.val; if ((this.val = this.mgb(bytes)) != prev) for(var win of CustomizableUI.windows) { var lab = win.document.getElementById(id); if (lab) lab.value = this.val; } }, mgb: bytes => bytes < 1073741824 ? String(Math.round(bytes / 1048576)) : (bytes / 1073741824).toFixed(2) }).init("browser-delayed-startup-finished"))("ucf-mem-mix-indicator");
и рядом создать файл memreporter.jsm
var EXPORTED_SYMBOLS = ["UCFMemIndReporterChild"]; var ai = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime); var prop = ai.processType == ai.PROCESS_TYPE_DEFAULT ? "resident" : "residentUnique"; var pid = ai.processID; var mrm = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager); class UCFMemIndReporterChild extends JSProcessActorChild {receiveMessage() {return [pid, mrm[prop]];}}
Подсчёт такой:
родительский процесс — nsIMemoryReporterManager.resident
дочерние DOM-процессы — nsIMemoryReporterManager.residentUnique
остальные процессы — ChildProcInfoDictionary.memory
Тогда на memreduct реагирует, и даже слишком,
какая-то другая крайность, совсем нереалистично.
уже этот код не работает
Ага. Собрали всё в один файл, зацени.
То есть нужно убрать из адеса субчасть операционной системы. Вариант:
(async () => { var url = `${ AppConstants.SOURCE_REVISION_URL.replace("rev", "raw-file") }/dom/events/ShortcutKeyDefinitions.cpp`; var text = await (await fetch(url)).text(); var platform = {win: "Win", linux: "Linux", macosx: "macOS"}[AppConstants.platform]; var re = new RegExp( '(?:u"keypress", +)' + '(?:u")?(.+?)(?:")?, +'.repeat(3) + `(?:u")(cmd_.+)(?="},.+${platform}(.+)?$)`, "gm" ); var pad = function(arr) { return `${arr[0].padEnd(this, " ")} ${arr[1]}`; } var result = []; var blocks = text.split("ShortcutKeyData ShortcutKeys::s").slice(1); for(var block of blocks) { var res, max = 0, arr = []; while((res = re.exec(block))) { var [, vk, key, mod, cmd] = res; if (key == " ") key = "<Space>"; max = Math.max(max, cmd.length); if (mod != "nullptr") { var mods = []; if (mod.includes("control")) mods.push("Ctrl"); if (mod.includes("accel")) mods.push("Accel"); if (mod.includes("shift")) mods.push("Shift"); if (mod.includes("alt")) mods.push("Alt"); mod = mods.join("+") + "+"; } else mod = ""; arr.push([cmd, mod + (vk != "nullptr" ? vk : key)]); } arr = arr.map(pad, max); arr.unshift(block.slice(0, block.indexOf("[")) + ":\n"); result.push(arr.join("\n")); } text = result.join("\n\n\n"); var file = Services.dirsvc.get("ProfD", Ci.nsIFile); file.append("TextToEditor.txt"); cbu.writeFile(file.path, text); file.launch(); })();
Отредактировано Dumby (08-11-2021 15:42:27)
Отсутствует
Dumby
Ладно, about:processes - не изменяются значения, а автоочистку прикрутить тоже никак?
"Andrey_Krropotkin пишет
уже этот код не работает"
И что это за код? Для чего?
Отредактировано ВВП (08-11-2021 17:58:23)
Отсутствует
Dumby ВВП от души спасибо за рабочюю кнопку очистки памяти!!!
Отсутствует
voqabuhe
Рядом с custom_script.js надо иметь файл memreporter.jsm . Такого содержания:
(async id => ({ delay: 2e3, xul: ` <hbox id="${id}" value="ram" tooltiptext="ЛКМ: Очистить Память" > <label id="${id += "-label"}"/> </hbox> `, css: ` min-height: 26px !important; height: 26px !important; border-radius: 3px !important; padding: 0px 4px 0px !important; color: #00ffff !important; font-size: 15px !important; margin: 0px 1px 1px 5px !important; font-weight: 400 !important; font-family: segoe ui !important; background: linear-gradient(rgb(72, 85, 108),rgb(20, 25, 34)) !important; `, launch() { var file = Services.dirsvc.get("ProfD", Ci.nsIFile); ["memory", "start.vbs"].forEach(file.append); (this.launch = file.launch)(); }, val: "", name: "UCFMemIndReporter", init(topic, mm) { Services.obs.addObserver(mm = this, topic); Services.obs.addObserver(function quit(s, t) { this.timer?.cancel(); Services.obs.removeObserver(mm, topic); Services.obs.removeObserver(quit, t); }, "quit-application-granted"); }, observe(win) { var df = win.MozXULElement.parseXULToFragment(this.xul); this.click = e => e.button || this.launch(); this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); ChromeUtils.registerProcessActor(this.name, { includeParent: true, child: {moduleURI: "chrome://user_chrome_files/content/custom_scripts/memreporter.jsm"} }); (this.observe = async win => { this.timer.cancel(); await new Promise(win.requestAnimationFrame); var clone = win.document.importNode(df, true); var hbox = clone.firstChild; win.document.getElementById("page-action-buttons").append(clone); hbox.onclick = this.click; hbox.style.cssText = this.css; hbox.firstChild.style.setProperty("margin", "0", "important"); this.notify(); })(win); }, async notify() { var bytes = 0, pids = []; for(var dp of ChromeUtils.getAllDOMProcesses()) try { let [pid, mem] = await dp.getActor(this.name).sendQuery(""); pids.push(pid); bytes += mem; } catch {} var {children} = await ChromeUtils.requestProcInfo(); for(var child of children) if (!pids.includes(child.pid)) bytes += child.memory; this.timer.initWithCallback(this, this.delay, this.timer.TYPE_ONE_SHOT); var prev = this.val; if ((this.val = this.mgb(bytes)) != prev) for(var win of CustomizableUI.windows) { var lab = win.document.getElementById(id); if (lab) lab.value = this.val; } bytes > 950000000 && this.launch(); }, mgb: bytes => bytes < 1073741824 ? String(Math.round(bytes / 1048576)) : (bytes / 1073741824).toFixed(2) }).init("browser-delayed-startup-finished"))("ucf-mem-mix-indicator");
И в профиле иметь эту папку https://www.upload.ee/files/13618312/memory.rar.html
Вида х64 !
Отредактировано ВВП (08-11-2021 21:39:30)
Отсутствует
ВВП
Спасибо. А по сравнению с соответствующей кнопкой на about:memory есть преимущество в плане очистки, в смысле больше освобождается памяти, или нет?
Отредактировано voqabuhe (08-11-2021 22:33:37)
Отсутствует
voqabuhe
Так нажми на кнопки и сравни.
Для тех кто не продвинулся, типа, скрипты не подключаются ,кнопка...ДА, и профиль надо чистить поле рихтовки. startupCache - убрать !
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%u0412%u043B%u043B/%u0412%u044B%u043A%u043B%20CustomScripts%3C/name%3E%0A%20%20%3Cimage%3E%3C%21%5BCDATA%5Bdata%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACq0lEQVR42n2TW0hUQRjH/zPnshd3dU3OpruaQdJFQirQsMWISAjqISiMVHopiSgEoR6CXqKIeggSeygqHwozHzT0LUgI8vIQFkWhJKaQbd42V3fbc/bcprNnY3Vja+CcGb75vt/85883BP8YksBvLCW0hICS76Y2P68b4Vx55O/AYbfnyBVfSVuNw1Pt5Gk+mImkosXfJWMfbscWOvoVuScnQCBwtEulHefLKloQjwIrP7PxzjzA7UHn7EzPxdjSOdlkK1mAh1Lw6dmtlc2Y/AwwIx3s60vPDacATbGyBSAQRPfXLy8bY9Gj1o5uA0Iu58GhiqpBhKcB01g7dXjYnlgotCaZcwBeD+q/TTe90vVnNqDLH3jRWFhwjM3/yCSaNC2O6DoYz2fiVDVA/H70zs2OnEgodcRJiHciEJwqhy7punU6R62PB9/UDJxpsYu06l2gVMhAONGBsJJIbo+ubiMBntvyqbRk3KupQko8ISkLTBBNgzg6lgFkhtttwSgSmoqdS8shUmwBPgal8QLCbADMdB6TE3CPvM8CGF637Ttn/X/pGqoWlvcR63aet5ukyUqBL1YJswHENMFcLngGBu3CxKHaP9qtUpOBtxRMK7K8Zy66w3bqlt/7/JLkOxnXdJCUfDAwUUT+wGu7Lla/F+DXPMizTL2/GHlzISIfsAHlIq0ZKi8cLRCd1EgZaQHyb94DrdptF6hdnZC7H6flEwrF1FA3Ezk+oZp9mUZq8YntdzdLrRoj0JMKeMZltbhhXY8XBIjW+mo40nsnojSkHFvfrHyjT7hxLei7HHA6qaaZMFQts+nKc2BRVnA9vNL5KKq2WaHVnI+pTCD7T0vu1jqvo3aDrhVRjpAo46LDcXXsSSTxYEpl/f99jetGkYeiONV8cROL1jyXK+k3s3kAMT5aaccAAAAASUVORK5CYII%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*/%0Athis._handleClick%20%3D%28%29%3D%3E%20%7B%0A%20%20%20cbu.setPrefs%28s%2C%20cbu.getPrefs%28s%29%20%3D%3D%20true%20%3F%20false%20%3A%20true%29%3B%0A%7D%3B%0Avar%20s%20%3D%20%22extensions.user_chrome_files.custom_script%22%3B%0A%0Afunction%20toggleImage%28%29%20%7B%0A%20%20%20var%20val%20%3D%20cbu.getPrefs%28s%29%3B%0A%20%20%20var%20%7Bicon%7D%20%3D%20self%3B%0A%20%20%20icon.src%20%3D%20cbu.getPrefs%28s%29%20%3D%3D%20false%0A%20%20%20%3F%20self.image%0A%20%20%20%3A%20%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAqNJREFUeNp8k09IFFEcx3/vzZudUVd3VsVsNUEhBOmUbBSh/blo1CEirGjzZh2kDaluHYSEbpFIghR18FBCHqJDFERIddMiqKBDkImr667urKszzsx7b3pv0TFraeDH+/f7fd73N7/fQ77vQ6lPC9fuChn1uwEh5JqLaaeQSZXyQ38DatqOnWw60T+gN8fjVDWquI8AOebaxuynz6nXoyMrX15NlAQgHNJaewZH6ruTfVlLB75eAAzbcE+rhCqNQvbt6MSvyVtXmGfn5T7Zcmg9P/SwrvtGIr1gAmY2ILH3IFFdPOubyANZy0HBJhA9OnDOR7ohMjslLqdYOhjN8eN1Ry4nMnPLgFwXfMaKFi3DReMbTnGNXQdscwUi8d6uipaOnkBBrKP3qmWJKbUD0cjncOZ+CqjYIGg7Z8o9CKk6RPZf6hcqnmJF1SsrGuOHvXULVGCgIQblCofEwUp4kYzBy2sxoC4LAKoAg2NBuKm9HYXCezApM+qARAzwXEBSOuXgOhTG35k7qiMh0lTggCgFNRTWFC3SQEAQmesBIoIs6UKuIgJcj/9T8zIsgqUYmScrTnzsWbm0Zy4sy78pFWypiGrbJdRF3tIwF1DGxSgUrWZsZuVSmDNvzfw+NaUgUgyWDnJkfyjwKQNFqtu8AAvf1R/vp31mzxXLmJ4Zv7uRnedYtM6WisELDQEg0Sn6gW4Gixy9fBaWZx7fE33Ag06s3ndxuKXrdlIcg+N4oGhkR/5SBVFVAKzB7Js7k9mPYz07AKKmJLL39FBTx/WbuhHD3PfEpTQAhNRycApLMPdh+FHu65MBEbda8jGp4YbO2razyarGA4coidZgQcYsbxbmp2ey356Nufmfz//7GoMDhGoQqagXU+zT9YzwWyzl91uAAQDUCFTmpTZ8qAAAAABJRU5ErkJggg%3D%3D%22%3B%20%0A%20%20%20self.tooltipText%20%3D%20val%20%3F%20%27%u0414%u0430%20CustomScripts%27%20%3A%20%27%u041D%u0435%u0442%20CustomScripts%27%3B%20%0A%20%20%20cbu.setPrefs%28%22extensions.user_chrome_files.custom_script_win%22%2C%20val%20%3F%20true%20%3A%20false%29%3B%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%0AtoggleImage%28%29%3B%0AServices.prefs.addObserver%28%20s%2C%20toggleImage%2C%20false%20%29%3B%0AaddDestructor%28function%28%29%20%7B%20gPrefService.removeObserver%28%20s%2C%20toggleImage%2C%20false%20%29%20%7D%29%3B%20%20%0A%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
Отредактировано ВВП (09-11-2021 12:26:19)
Отсутствует
Dumby
Я извиняюсь, нельзя еще в кодом memory поработать ? Task - чуть не ноль показывает на пустой вкладке, а на индикаторе 140-160 мгб , в 93 - 60мгб. Кажись графич.редактор не трогает очистка...Это расхождение в цифрах парит немного...
Отсутствует
Так нажми на кнопки и сравни.
Дык я её не устанавливал, для этого и спросил, чтоб решить, нужна она мне, или ограничится кнопкой memoryMinimizationButton.uc.js, которая как раз работает идентично кнопке на about:memory.
Отсутствует
Эта шняга 18года вообще не подходить к 94. Даже не парься.
Дык её же в своё время Dumby правил и она у меня, как уже сказал, вполне работает.
// ==UserScript== // https://github.com/alice0775/userChrome.js/blob/master/71/memoryMinimizationButton.uc.js // @name memoryMinimizationButton.uc.js // @namespace http://space.geocities.yahoo.co.jp/gl/alice0775 // @description memory minimization button // @charset utf-8 // @include main // @compatibility Firefox 60 // @author Alice0775 // @version 2018/10/09 00:00 fix CSS // @version 2018/09/07 23:00 fix initial visual status // ==/UserScript== var memoryMinimizationButton = { get memoryMinimizationButton(){ return document.getElementById("memoryMinimizationButton"); }, get statusinfo() { if ("StatusPanel" in window) { // fx61+ return StatusPanel._labelElement.value; } else { return XULBrowserWindow.statusTextField.label; } }, set statusinfo(val) { if ("StatusPanel" in window) { // fx61+ StatusPanel._label = val; } else { XULBrowserWindow.statusTextField.label = val; } if(this._statusinfotimer) clearTimeout(this._statusinfotimer); this._statusinfotimer = setTimeout(() => {this.hideStatusInfo();}, 2000); this._laststatusinfo = val; return val; }, init: function() { let style = ` #memoryMinimizationButton { width: 16px; height: 16px; list-style-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjEuMWMqnEsAAAFdSURBVFhH7VbLbsMwDMsef5dc8z/53F13GXZYm5kaZciqnKro2hxaAkRkmkqI2gI6KNZ1vStPEJluyS6WZVlB3xDpWc3q/Ewf6ASClwicLkhojc5PxaDvgQIU4dWSPjEa/Z1y1ed5fqPUeCmJVhAGUC9YNzz4ghNEelYDrI5aAozjeNyD5QBqgF34DJAN8GN4oGb3cJ527fftumEqgAVurdk7Um680zR92bXWEdMBWB+s14+TegFf93hpgF5dgylK/cFSPSGvOgKA9afWgP4y+lR/xKuOwMN6AdwFXff4H0eAqfhWnU9Mhdx+rrtMBSjER3TUtLYaqOMYjaldN8wGuBmfAWqAcmMPe1ACYF6lIBUZXXFO29I3/5IVoFMpcLoA2iX96gVLiBb0bb6gINSy/WLsgb4HDgBD0BzqXsv0i8nDm+/JCC8lKW5zY4SGvT9LBdbVS0g/64q4fxh+AZvdJHHKcZdFAAAAAElFTkSuQmCC'); } @media (min-resolution: 1.1dppx) { #memoryMinimizationButton { width: 32px; height: 32px; } } `.replace(/\s+/g, " "); let sss = Components.classes['@mozilla.org/content/style-sheet-service;1'] .getService(Components.interfaces.nsIStyleSheetService); let newURIParam = { aURL: 'data:text/css,' + encodeURIComponent(style), aOriginCharset: null, aBaseURI: null } let cssUri = Services.io.newURI(newURIParam.aURL, newURIParam.aOriginCharset, newURIParam.aBaseURI); sss.loadAndRegisterSheet(cssUri, sss.AUTHOR_SHEET); if (this.memoryMinimizationButton) return; Components.utils.import("resource:///modules/CustomizableUI.jsm"); try { CustomizableUI.createWidget({ //must run createWidget before windowListener.register because the register function needs the button added first id: 'memoryMinimizationButton', type: 'custom', defaultArea: CustomizableUI.AREA_NAVBAR, onBuild: function(aDocument) { var toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton'); var props = { id: "memoryMinimizationButton", class: "toolbarbutton-1 chromeclass-toolbar-additional", tooltiptext: "Memory minimization", oncommand: "memoryMinimizationButton.doMinimize(event);", type: CustomizableUI.TYPE_TOOLBAR, label: "Memory minimization", removable: "true" }; for (var p in props) { toolbaritem.setAttribute(p, props[p]); } return toolbaritem; }, }); } catch(ee) {} }, doMinimize: function(event) { function doGlobalGC() { Services.obs.notifyObservers(null, "child-gc-request"); Cu.forceGC(); } function doCC() { Services.obs.notifyObservers(null, "child-cc-request"); if (typeof window.windowUtils != "undefined") window.windowUtils.cycleCollect(); else window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindowUtils).cycleCollect(); } function doMemMinimize() { Services.obs.notifyObservers(null, "child-mmu-request"); var gMgr = Cc["@mozilla.org/memory-reporter-manager;1"] .getService(Ci.nsIMemoryReporterManager); gMgr.minimizeMemoryUsage(() => memoryMinimizationButton.displayStatus("Memory minimization done")); } function sendHeapMinNotifications() { function runSoon(f) { var tm = Cc["@mozilla.org/thread-manager;1"] .getService(Ci.nsIThreadManager); tm.mainThread.dispatch({ run: f }, Ci.nsIThread.DISPATCH_NORMAL); } function sendHeapMinNotificationsInner() { var os = Cc["@mozilla.org/observer-service;1"] .getService(Ci.nsIObserverService); os.notifyObservers(null, "memory-pressure", "heap-minimize"); if (++j < 3) runSoon(sendHeapMinNotificationsInner); } var j = 0; sendHeapMinNotificationsInner(); } this.displayStatus("Memory minimization start") doGlobalGC(); doCC(); //sendHeapMinNotifications(); setTimeout(()=> {doMemMinimize();}, 1000); }, _statusinfotimer: null, _laststatusinfo: null, displayStatus: function(val) { this.statusinfo = val; }, hideStatusInfo: function() { if(this._statusinfotimer) clearTimeout(this._statusinfotimer); this._statusinfotimer = null; if (this._laststatusinfo == this.statusinfo) this.statusinfo = ""; } } memoryMinimizationButton.init();
Отредактировано voqabuhe (09-11-2021 21:19:02)
Отсутствует