Полезная информация

Пользователи не любят читать документацию. Станьте оригинальным, будьте не как все. Ознакомьтесь с нашей базой знаний.

№1662616-11-2022 14:07:25

ВВП
Участник
 
Группа: Members
Зарегистрирован: 13-03-2021
Сообщений: 337
UA: Firefox 106.0

Re: Custom Buttons

Dumby
Такая шняга есть ,приходиться стилем..

скрытый текст

Выделить код

Код:

#PopupSearchAutoComplete >.search-one-offs {background: #111 !important;-moz-appearance: menuarrow !important; margin: 0px -4px 0px 0px !important; padding: 0 !important;}


И не только там, иначе arrow не того , как меню выпадает , вот раньше в префке что-то мастырил и без стиля обходился...

Отсутствует

 

№1662716-11-2022 14:12:10

ifln
Участник
 
Группа: Members
Зарегистрирован: 20-09-2013
Сообщений: 235
UA: Firefox 102.0

Re: Custom Buttons

Dumby пишет

И запускатор

В последней строчке после точки jsm не надо добавить?

Отсутствует

 

№1662816-11-2022 16:36:42

Dumby
Участник
 
Группа: Members
Зарегистрирован: 12-08-2012
Сообщений: 2259
UA: Firefox 78.0

Re: Custom Buttons

ВВП пишет

arrow не того

Ничего удивительного, от них же разрабы отказались.
Мне, кстати, эти arrow-треугольники тоже не слишком-то нравились.


ifln пишет

В последней строчке после точки jsm не надо добавить?

Надеюсь нет. Расширение добавляется в этой строке:
try {var exp = impESM(xp + "sys.mjs");} catch {exp = impJSM(xp + "jsm");}


Пока catch. Конвертация jsm'ок идёт как-то вяло, но Cu.loadedESModules
уже показывает ≈ 170 штук, однако аддонские jsm'ки, вроде, ещё даже в мете не упоминаются.
Так что это просто так, на будущее, если ничего неожиданного не случится.

Отсутствует

 

№1662916-11-2022 17:14:04

ВВП
Участник
 
Группа: Members
Зарегистрирован: 13-03-2021
Сообщений: 337
UA: Firefox 101.0

Re: Custom Buttons

Dumby
Не в треугольнике дело. Нажал на кн. поиск и второй раз окно не выпадает.
qf8ds9lw.png

Отсутствует

 

№1663016-11-2022 18:29:04

Dumby
Участник
 
Группа: Members
Зарегистрирован: 12-08-2012
Сообщений: 2259
UA: Firefox 78.0

Re: Custom Buttons

ВВП пишет

Нажал на кн. поиск и второй раз окно не выпадает.

В той Netscape-сборке (на Gecko 106.0), которую ты давал,
«окно» (panel#PopupSearchAutoComplete) выпадает как положено.


Значит в 107 что-то сломалось, надо полагать.
Тогда, получается, нужно снова сборку смотреть, когда будет время,
возможно получится увидеть это невыпадение и раскопать причину, но не факт.

Отсутствует

 

№1663116-11-2022 18:39:25

ВВП
Участник
 
Группа: Members
Зарегистрирован: 13-03-2021
Сообщений: 337
UA: Firefox 101.0

Re: Custom Buttons

Dumby
Так я где то -moz-appearance: menuarrow !important; туда влепил...А "удаление всей истории" ? Так такая же проблема...

Отсутствует

 

№1663228-11-2022 02:05:50

unter_officer
Участник
 
Группа: Members
Откуда: Санкт-Петербург
Зарегистрирован: 27-03-2011
Сообщений: 605
UA: Firefox 102.0

Re: Custom Buttons

Dumby пишет

Если paxmod, то, наверно, это всё тот же пресловутый ограничительный
хардкод на загрузку модулей только по протоколам chrome: и resource:
(то есть file: и jar:file: идут лесом). Остальное не помню.
Хорошо, соберу что есть. Сам он, разумеется, лучше не стал. DOMi 7.0.10.

Dumby, не посмотрите DOM Inspector.
В [firefox] 107 перестал работать.


«The Truth Is Out There»

Отсутствует

 

№1663328-11-2022 02:22:05

Dumby
Участник
 
Группа: Members
Зарегистрирован: 12-08-2012
Сообщений: 2259
UA: Firefox 78.0

Re: Custom Buttons

unter_officer
Собирал себе какой-то.

Отсутствует

 

№1663428-11-2022 14:31:20

unter_officer
Участник
 
Группа: Members
Откуда: Санкт-Петербург
Зарегистрирован: 27-03-2011
Сообщений: 605
UA: Firefox 102.0

Re: Custom Buttons

Dumby, большое спасибо!


«The Truth Is Out There»

Отсутствует

 

№1663530-11-2022 22:00:30

ВВП
Участник
 
Группа: Members
Зарегистрирован: 13-03-2021
Сообщений: 337
UA: Firefox 107.0

Re: Custom Buttons

Dumby
gBrowser.removeAllTabsBut(gBrowser.selectedTab);
Нет другого варианта ?  Долго обьяснять, undoclose кнопка сдохла,рихтанул модули session И код этот тоже того...
И это placesCmd_undoRemove -воостановить закладку тоже пропало, куда рыть ? Комана работает, пункт не появляется...
Может кн. undo подрихтовать(document.popupNode), может это ? (this.parentNode.triggerNode), а то геммора много с SessionStore.jsm...

скрытый текст

Выделить код

Код:

// http://infocatcher.ucoz.net/js/cb/undoCloseTabs.js
// https://forum.mozilla-russia.org/viewtopic.php?id=56267
// https://github.com/Infocatcher/Custom_Buttons/tree/master/Undo_Close_Tabs

// Undo Close Tabs button for Custom Buttons
// (code for "initialization" section)

// (c) Infocatcher 2009-2015, 2017-2018
// version 0.3.3.1 - 2018-08-01

var options = {
    menuTemplate: [    
        "separator",            
        "separator",
        "closedTabs",
        "separator",
        "restoreClosedTabs",
        "clearClosedTabs",
        "separator", 
        "separator",
        "restoreLastSession",
        "separator"     
    ],
    showInTabContextMenu: false,
    /*
    menuTemplateTabContext: [ // like menuTemplate
        "closedTabs",
        "separator",
        "restoreClosedTabs",
        "clearClosedTabs"
    ],
    */
    windowItemTemplate: "(%count) %title",
    windowSelectedTabPrefix: "*",
    buttonTipTemplate: ["header", "title", "url", "closedAt"],
    itemTipTemplate: ["title", "url", "closedAt"],
    hideRestoreAllForSingleEntry: false,
    allowDeleteEntries: true,
    accesskeys: { // Empty string ("") to disable or string with possible values ("0123...", "abcd...")
        closedTabs: "",
        closedWindows: ""
    },
    accesskeyPostfix: " ", // <accesskey><postfix><label>
    openMenuOnMouseover: false,
    useMenu: false,
    rightClickToUndoCloseTab: false // Useful with "useMenu: true"
};

function _localize(sid) {
    var strings = {
        en: {
            restoreTab: "Восстановить последнюю вкладку \nИли сессию",

            restoreAllTabs: "Restore all tabs",
            restoreAllTabsAccesskey: "t",
            clearTabsHistory: "Clear history of closed tabs",
            clearTabsHistoryAccesskey: "b",

            restoreAllWindows: "Restore all windows",
            restoreAllWindowsAccesskey: "w",
            clearWindowsHistory: "Clear history of closed windows",
            clearWindowsHistoryAccesskey: "d",

            clearAllHistory: "Clear all history",
            clearAllHistoryAccesskey: "C",

            restoreLastSession: "Restore last session",
            restoreLastSessionAccesskey: "s",

            deleteUndoEntry: "Delete",

            tabContextMenu: "Recently Closed Tabs",
            tabContextMenuAccesskey: "y",

            itemTip: "%ago ago, %date",
            day: "d"
        },
        ru: {
            restoreTab: "Восстановить последнюю вкладку \nИли сессию",

            restoreAllTabs: "Восстановить все вкладки",
            restoreAllTabsAccesskey: "л",
            clearTabsHistory: "Очистить историю закрытых вкладок",
            clearTabsHistoryAccesskey: "д",

            restoreAllWindows: "Восстановить все окна",
            restoreAllWindowsAccesskey: "о",
            clearWindowsHistory: "Очистить историю закрытых окон",
            clearWindowsHistoryAccesskey: "н",

            clearAllHistory: "Очистить всю историю",
            clearAllHistoryAccesskey: "ч",

            restoreLastSession: "Восстановить последнюю сессию",
            restoreLastSessionAccesskey: "с",

            deleteUndoEntry: "Удалить",

            tabContextMenu: "Недавно закрытые вкладки",
            tabContextMenuAccesskey: "о",

            itemTip: "%ago назад, %date",
            day: "д"
        }
    };
    var locale = (function() {
        if("Services" in window && "locale" in Services) {
            var locales = Services.locale.requestedLocales // Firefox 64+
                || Services.locale.getRequestedLocales && Services.locale.getRequestedLocales();
            if(locales)
                return locales[0];
        }
        var prefs = "Services" in window && Services.prefs
            || Components.classes["@mozilla.org/preferences-service;1"]
                .getService(Components.interfaces.nsIPrefBranch);
        function pref(name, type) {
            return prefs.getPrefType(name) != prefs.PREF_INVALID ? prefs["get" + type + "Pref"](name) : undefined;
        }
        if(!pref("intl.locale.matchOS", "Bool")) { // Also see https://bugzilla.mozilla.org/show_bug.cgi?id=1414390
            var locale = pref("general.useragent.locale", "Char");
            if(locale && locale.substr(0, 9) != "chrome://")
                return locale;
        }
        return Components.classes["@mozilla.org/chrome/chrome-registry;1"]
            .getService(Components.interfaces.nsIXULChromeRegistry)
            .getSelectedLocale("global");
    })().match(/^[a-z]*/)[0];
    _localize = function(sid) {
        return strings[locale] && strings[locale][sid] || strings.en[sid] || sid;
    };
    return _localize.apply(this, arguments);
}

var JSON = "JSON" in window
    ? window.JSON
    : "nsIJSON" in Components.interfaces
        ? {
            parse: function(s) {
                return Components.classes["@mozilla.org/dom/json;1"]
                    .createInstance(Components.interfaces.nsIJSON)
                    .decode(s);
            }
        }
        : {
            parse: function(s) {
                return Components.utils.evalInSandbox("(" + s + ")", new Components.utils.Sandbox("about:blank"));
            }
        };

this.onclick = function(e) {
    if(e.target != this)
        return;
    if(e.button == 1 || e.button == 0 && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey))

   {  
	if(Services.prompt.confirm(null, null, "     Удалить список вкладок и сессий ?")) {
		this.undoCloseTabsList.clearAllLists();
		SessionStore.canRestoreLastSession = false;
                document.querySelector(
    "#mainPopupSet > tooltip[onpopupshowing*=undoCloseTabsList]"
)?.undoCloseTabsList.updUI();

	}
}

    else if(
        e.button == 0
        || e.button == 2 && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey
            && this.undoCloseTabsList.options.rightClickToUndoCloseTab
    ) {
        if(
            e.button == 0 && !this.undoCloseTabsList.options.useMenu
            || e.button == 2 && this.undoCloseTabsList.options.rightClickToUndoCloseTab
        ) {
            if(this.undoCloseTabsList.closedTabCount)
                this.undoCloseTabsList.undoCloseTab();
            else
                this.undoCloseTabsList.drawUndoList() && this.undoCloseTabsList.showMenu(e);
        }
        // Allow use "command" section only from hotkey:
        e.preventDefault();
        e.stopPropagation();
    }
};
if(!this.hasOwnProperty("defaultContextId"))
    this.defaultContextId = this.getAttribute("context") || "custombuttons-contextpopup";
this.onmousedown = function(e) {
    if(e.target != this)
        return;
    if(this.undoCloseTabsList.options.useMenu) {
        if(e.button == 0)
            this.undoCloseTabsList.drawUndoList();
    }
    else if(e.button == 2) {
        var showCbMenu = e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || !this.undoCloseTabsList.drawUndoList();
        this.setAttribute(
            "context",
            showCbMenu
                ? this.defaultContextId
                : this.undoCloseTabsList.mpId
        );
    }
};
this.onmouseover = function(e) {
    if(e.target != this)
        return;
    if(!this.disabled)
        this.undoCloseTabsList.updUI();
    this.undoCloseTabsList.options.useMenu && Array.prototype.some.call(
        this.parentNode.getElementsByTagName("*"),
        function(node) {
            if(
                node != this
                && node.namespaceURI == xulns
                // See https://github.com/Infocatcher/Custom_Buttons/issues/28
                //&& node.boxObject
                //&& node.boxObject instanceof Components.interfaces.nsIMenuBoxObject
                && "open" in node
                && node.open
                && node.getElementsByTagName("menupopup").length
                && this.undoCloseTabsList.drawUndoList()
            ) {
                node.open = false;
                this.open = true;
                return true;
            }
            return false;
        },
        this
    );
    if(
        this.undoCloseTabsList.options.openMenuOnMouseover
        && this.undoCloseTabsList.drawUndoList()
    )
        this.undoCloseTabsList.openMenu();
};

this.undoCloseTabsList = {
	button: this,
	options: options,
	mpId: this.id + "-context",
	cmId: this.id + "-contextSub",
	tcmId: this.id + "-tabContextMenu",
	tipId: this.id + "-tooltip",
	errPrefix: "[Custom Buttons :: Undo Close Tabs List]: ",
	get mp() {
		var btn = this.button;
		var mp = btn.getElementsByTagName("menupopup");
		mp = mp.length && mp[0];
		mp && mp.parentNode.removeChild(mp);
		mp = this.createElement("menupopup", {
			id: this.mpId,
			onclick: "this.parentNode.undoCloseTabsList.checkForMiddleClick(event);",
			onpopupshowing: "if(event.target == this) document.popupNode = this.parentNode;",
			onpopuphidden: "if(event.target == this) document.popupNode = null;"
		});
		if(this.cm)
			mp.setAttribute("context", this.cmId);
		var tb = btn.parentNode;
		if(
			this.options.useMenu
			&& tb.getAttribute("orient") == "vertical"
		) {
			// https://addons.mozilla.org/firefox/addon/vertical-toolbar/
			var isRight = tb.parentNode.getAttribute("placement") == "right";
			mp.setAttribute("position", isRight ? "start_before" : "end_before");
		}
		delete this.mp;
		return this.mp = btn.appendChild(mp);
	},
	get useCentextMenu() {
		delete this.useCentextMenu;
		return this.useCentextMenu = this.options.allowDeleteEntries
			&& ("forgetClosedTab" in this.ss || "forgetClosedWindow" in this.ss);
	},
	get cm() {
		delete this.cm;
		if(!this.useCentextMenu)
			return this.cm = null;
		var cm = document.getElementById(this.cmId);
		cm && cm.parentNode.removeChild(cm);
		cm = this.createElement("menupopup", {
			id: this.cmId,
			onpopupshowing: "return this.undoCloseTabsList.canDeleteUndoEntry(this.triggerNode || document.popupNode);"
		});
		var mi = this.createElement("menuitem", {
			oncommand: "this.parentNode.undoCloseTabsList.deleteUndoEntry(this.parentNode.triggerNode || document.popupNode);",
			label: _localize("deleteUndoEntry"),
			closemenu: "single"
		});
		cm.appendChild(mi);
		cm.undoCloseTabsList = this;
		return this.cm = document.getElementById("mainPopupSet").appendChild(cm);
	},
	get cbMenu() {
		var cbPopup = document.getElementById(this.button.defaultContextId);
		if(!cbPopup) {
			Components.utils.reportError(this.errPrefix + "cb menu not found");
			return this.cbMenu = null;
		}
		cbPopup = cbPopup.cloneNode(true);
		var id = "-" + this.button.id.match(/\d*$/)[0] + "-cloned";
		cbPopup.id += id;
		Array.prototype.slice.call(cbPopup.getElementsByAttribute("id", "*")).forEach(function(node) {
			node.id += id;
		});
		var menu = this.createElement("menu", {
			label: _localize("buttonMenu"),
			accesskey: _localize("buttonMenuAccesskey")
		});
		menu.appendChild(cbPopup);
		cbPopup.setAttribute(
			"onpopupshowing",
			'\
			var btn = document.popupNode = this.parentNode.parentNode.parentNode\n\
				.undoCloseTabsList.button;\n\
			custombutton.setContextMenuVisibility(btn);'
		);
		delete this.cbMenu;
		return this.cbMenu = menu;
	},
	get ss() {
		delete this.ss;
		return this.ss = "nsISessionStore" in Components.interfaces
			? (
				Components.classes["@mozilla.org/browser/sessionstore;1"]
				|| Components.classes["@mozilla.org/suite/sessionstore;1"]
			).getService(Components.interfaces.nsISessionStore)
			: SessionStore; // Firefox 61+ https://bugzilla.mozilla.org/show_bug.cgi?id=1450559
	},
	get appInfo() {
		delete this.appInfo;
		return this.appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
			.getService(Components.interfaces.nsIXULAppInfo);
	},
	get appVersion() {
		delete this.appVersion;
		return this.appVersion = parseFloat(this.appInfo.version);
	},
	get platformVersion() {
		delete this.platformVersion;
		return this.platformVersion = parseFloat(this.appInfo.platformVersion);
	},
	get appName() {
		delete this.appName;
		return this.appName = this.appInfo.name;
	},

	init: function() {
		window.addEventListener("TabClose",       this, false);
		window.addEventListener("SSTabRestoring", this, false);
		window.addEventListener("unload",         this, false);
		if(this.appName == "SeaMonkey") // No SSTab* events in SeaMonkey
			window.addEventListener("TabOpen", this, false);
		setTimeout(function(_this) {
			_this.mp.addEventListener("DOMMenuItemActive",   _this, false);
			_this.mp.addEventListener("DOMMenuItemInactive", _this, false);
			_this.initTooltip();
		}, 50, this);
		this.addPbExitObserver(true);
		this.updUIGlobal();
		if(this.options.showInTabContextMenu) setTimeout(function(_this) {
			_this.initTabContext();
		}, 100, this);
	},
	initTabContext: function() {
		var origMi = this.tabContextUndoClose;
		if(!origMi) {
			LOG("Can't find \"Undo Close Tab\" item in tab context menu");
			return;
		}
		var menu = document.getElementById(this.tcmId);
		menu && menu.parentNode.removeChild(menu); // For SeaMonkey
		menu = this.createElement("menu", {
			id: this.tcmId,
			label: _localize("tabContextMenu"),
			accesskey: _localize("tabContextMenuAccesskey"),
			tooltip: this.tipId,
			popupsinherittooltip: "true"
		});
		menu.undoCloseTabsList = this;
		menu.onclick = function(e) {
			if(e.target != this)
				return;
			if(e.button == 1 || e.button == 0 && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
				if(this.undoCloseTabsList.closedTabCount) {
					this.undoCloseTabsList.undoCloseTab();
					closeMenus(this);
				}
			}
		};
		var origMp = this.mp;
		var mp = origMp.cloneNode(true);
		mp.id = this.button.id + "-tabContext";
		var _this = this;
		function drawUndoList() {
			var ok = false;
			var opts = _this.options;
			var origTemplate = opts.menuTemplate;
			opts.menuTemplate = opts.menuTemplateTabContext || origTemplate;
			_this.mp = mp;
			try {
				ok = _this.drawUndoList();
			}
			catch(e) {
				Components.utils.reportError(e);
			}
			opts.menuTemplate = origTemplate;
			_this.mp = origMp;
			return ok;
		}
		function updMenu() {
			if(drawUndoList())
				menu.removeAttribute("disabled");
			else
				menu.setAttribute("disabled", "true");
		}
		mp._updatePopup = function(e) {
			if(e.target != this)
				return;
			document.popupNode = _this.button;
			drawUndoList();
		};
		mp.setAttribute("onpopupshowing", "this._updatePopup(event);");
		mp.onclick = function(e) {
			_this.checkForMiddleClick(e, updMenu);
		};
		menu.appendChild(mp);
		addEventListener("popupshown", function(e) {
			if(e.target == e.currentTarget)
				setTimeout(updMenu, 0); // Pseudo async
		}, false, origMi.parentNode);
		addEventListener("DOMMenuItemActive",   this, false, mp);
		addEventListener("DOMMenuItemInactive", this, false, mp);
		origMi.parentNode.insertBefore(menu, origMi.nextSibling);
		origMi.setAttribute("hidden", "true");
	},
	initTooltip: function() {
		var tip = document.getElementById(this.tipId);
		tip && tip.parentNode.removeChild(tip);
		tip = this.tip = this.createElement("tooltip", {
			id: this.tipId,
			orient: "vertical",
			onpopupshowing: "return this.undoCloseTabsList.updTooltip(this, this.triggerNode || document.tooltipNode);",
			onpopuphiding: "this.cancelUpdateTimer();"
		});
		tip.undoCloseTabsList = this;
		tip._updateTimer = 0;
		tip.initUpdateTimer = function(fn, context) {
			if(this._updateTimer)
				clearInterval(this._updateTimer);
			this._updateTimer = setInterval(function() {
				fn.call(context);
			}, 1000);
		};
		tip.cancelUpdateTimer = function() {
			if(this._updateTimer) {
				clearInterval(this._updateTimer);
				this._updateTimer = 0;
			}
		};
		var btn = this.button;
		btn.removeAttribute("tooltiptext");
		btn.setAttribute("tooltip", this.tipId);
		btn.setAttribute("popupsinherittooltip", "true");
		document.getElementById("mainPopupSet").appendChild(tip);
		if(this.appVersion >= 61 && "getAnonymousElementByAttribute" in document) {
			var label = document.getAnonymousElementByAttribute(tip, "class", "tooltip-label");
			label && label.remove();
		}
	},
	_hasPbExitObserver: false,
	addPbExitObserver: function(add) {
		if(add == this._hasPbExitObserver || !("Services" in window))
			return;
		this._hasPbExitObserver = add;
		if(add)
			Services.obs.addObserver(this, "last-pb-context-exited", false);
		else
			Services.obs.removeObserver(this, "last-pb-context-exited");
	},
	destroy: function() {
		window.removeEventListener("TabClose",       this, false);
		window.removeEventListener("SSTabRestoring", this, false);
		window.removeEventListener("unload",         this, false);
		if(this.appName == "SeaMonkey")
			window.removeEventListener("TabOpen", this, false);
		this.mp.removeEventListener("DOMMenuItemActive",   this, false);
		this.mp.removeEventListener("DOMMenuItemInactive", this, false);
		this.addPbExitObserver(false);
		var menu = document.getElementById(this.tcmId);
		if(menu) {
			menu.parentNode.removeChild(menu);
			this.tabContextUndoClose.removeAttribute("hidden");
		}
		var tip = this.tip;
		tip && tip.parentNode && tip.parentNode.removeChild(tip);
	},
	handleEvent: function(e) {
		switch(e.type) {
			case "TabClose":
			case "SSTabRestoring":
			case "TabOpen":
				setTimeout(function(_this) {
					_this.updUI();
				}, 0, this);
			break;
			case "DOMMenuItemActive":
			case "DOMMenuItemInactive":
				if(!("XULBrowserWindow" in window))
					break;
				XULBrowserWindow.setOverLink(
					e.type == "DOMMenuItemActive"
						? (e.target.getAttribute("cb_urlDecoded") || "")
							.replace(/ \n/g, ", ")
						: "",
					null
				);
			break;
			case "unload":
				this.updUIGlobal();
				this.destroy();
		}
	},
	observe: function(subject, topic, data) {
		if(topic == "last-pb-context-exited") {
			setTimeout(function(_this) {
				_this.updUI();
			}, 25, this);
		}
	},

	createElement: function(name, attrs) {
		var node = document.createElementNS(xulns, name);
		if(attrs) for(var attrName in attrs) if(attrs.hasOwnProperty(attrName))
			node.setAttribute(attrName, attrs[attrName]);
		return node;
	},
	get tabContextUndoClose() {
		return document.getElementById("context_undoCloseTab")
			|| document.getElementById("tabContextUndoCloseTab") // Firefox 2.0
			|| document.getAnonymousElementByAttribute(gBrowser, "tbattr", "tabbrowser-undoclosetab"); // SeaMonkey
	},
	get closedWindowCount() {
		if(!("getClosedWindowCount" in this.ss)) {
			delete this.closedWindowCount;
			return this.closedWindowCount = 0;
		}
		this.__defineGetter__("closedWindowCount", function() {
			return this.ss.getClosedWindowCount();
		});
		return this.closedWindowCount;
	},
	get closedTabCount() {
		return this.ss.getClosedTabCount(window);
	},
	undoCloseTab: function(i) {
		if("undoCloseTab" in window) // Firefox 2.0+
			undoCloseTab(i);
		else // SeaMonkey
			gBrowser.undoCloseTab(i);
	},
	clearUndoTabsList: function() {
		var closedTabCount = this.closedTabCount;
		if(!closedTabCount)
			return;
		if("forgetClosedTab" in this.ss) // Gecko 1.9.2+
			while(closedTabCount--)
				this.ss.forgetClosedTab(window, 0);
		else {
			// Doesn't work in SeaMonkey
			const pName = "browser.sessionstore.max_tabs_undo";
			let val = cbu.getPrefs(pName);
			cbu.setPrefs(pName, 0);
			cbu.setPrefs(pName, val);
		}
		this.updUIGlobal();
	},
	clearUndoWindowsList: function() {
		var closedWindowCount = this.closedWindowCount;
		if(!closedWindowCount)
			return;
		if("forgetClosedWindow" in this.ss) // Gecko 1.9.2+
			while(closedWindowCount--)
				this.ss.forgetClosedWindow(0);
		else
			this.ss.setWindowState(window, '{"windows":[{}],"_closedWindows":[]}', false);
		this.updUIGlobal();
	},
	clearAllLists: function() {
		this.clearUndoTabsList();
		this.clearUndoWindowsList();
	},
	canDeleteUndoEntry: function(mi) {
		switch(mi.getAttribute("cb_type")) {
			case "tab":    return "forgetClosedTab"    in this.ss;
			case "window": return "forgetClosedWindow" in this.ss;
		}
		return false;
	},
	deleteUndoEntry: function(mi) {
		var i = +mi.getAttribute("cb_index");
		if(mi.getAttribute("cb_type") == "window") {
			this.ss.forgetClosedWindow(i);
			this.updUIGlobal();
		}
		else {
			this.ss.forgetClosedTab(window, i);
			this.updUI();
		}
		this.drawUndoList();
	},
	showMenu: function(e, isContext, mp) {
		var btn = this.button;
		document.popupNode = btn.ownerDocument.popupNode = btn;
		if(!mp)
			mp = this.mp;
		if("openPopupAtScreen" in mp)
			mp.openPopupAtScreen(e.screenX, e.screenY, isContext);
		else
			mp.showPopup(btn, e.screenX, e.screenY, isContext ? "context" : "popup", null, null);
	},
	openMenu: function() {
		var mp = this.mp;
		if("openPopup" in mp)
			mp.openPopup(this.button, "after_start");
		else
			mp.showPopup(this.button, -1, -1, "popup", "bottomleft", "topleft");
	},
	drawUndoList: function() {
        var mp = this.mp;

        var wc = this.closedWindowCount;
        var tc = this.closedTabCount;
        var ss = this.ss;
        var canRestoreLastSession = "restoreLastSession" in ss && ss.canRestoreLastSession
        if(!wc && !tc && !canRestoreLastSession) {
            mp.textContent = "";
            mp.hidePopup();
            return false;
        }

		this._undoWindowItems = wc && JSON.parse(ss.getClosedWindowData());
		this._undoTabItems    = tc && JSON.parse(ss.getClosedTabData(window));
		var df = document.createDocumentFragment();

		this.options.menuTemplate.forEach(function(sid, indx, arr) {
			switch(sid) {
				case "closedWindows":
					wc && this.addUndoWindowsList(df);
				break;
				case "restoreClosedWindows":
					wc > this.options.hideRestoreAllForSingleEntry
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreAllWindows"),
						accesskey: _localize("restoreAllWindowsAccesskey"),
						oncommand: "for(var i = 0; i < " + this._undoWindowItems.length + "; ++i) undoCloseWindow();"
					}));
				break;
				case "clearClosedWindows":
					wc && df.appendChild(this.createElement("menuitem", {
						label: _localize("clearWindowsHistory"),
						accesskey: _localize("clearWindowsHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearUndoWindowsList();"
					}));
				break;
				case "closedTabs":
					tc && this.addUndoTabsList(df);
				break;
				case "restoreClosedTabs":
					tc > this.options.hideRestoreAllForSingleEntry
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreAllTabs"),
						accesskey: _localize("restoreAllTabsAccesskey"),
						oncommand: "for(var i = 0; i < " + this._undoTabItems.length + "; ++i) this.parentNode.parentNode.undoCloseTabsList.undoCloseTab();"
					}));
				break;
				case "clearClosedTabs":
					tc && df.appendChild(this.createElement("menuitem", {
						label: _localize("clearTabsHistory"),
						accesskey: _localize("clearTabsHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearUndoTabsList();"
					}));
				break;
				case "clearAll":
					(
						wc && tc
						|| wc && arr.indexOf("clearClosedWindows") == -1
						|| tc && arr.indexOf("clearClosedTabs") == -1
					)
					&& df.appendChild(this.createElement("menuitem", {
						label: _localize("clearAllHistory"),
						accesskey: _localize("clearAllHistoryAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.clearAllLists();"
					}));
				break;
				case "restoreLastSession": // Gecko 2.0+
					canRestoreLastSession && df.appendChild(this.createElement("menuitem", {
						label: _localize("restoreLastSession"),
						accesskey: _localize("restoreLastSessionAccesskey"),
						oncommand: "this.parentNode.parentNode.undoCloseTabsList.ss.restoreLastSession();"
					}));
				break;
				case "buttonMenu":
					let cbMenu = this.cbMenu;
					if(cbMenu)
						df.appendChild(cbMenu);
				break;
				case "separator":
					if(df.hasChildNodes() && df.lastChild.localName != "menuseparator")
						df.appendChild(document.createElementNS(xulns, "menuseparator"));
				break;
				default:
					Components.utils.reportError(this.errPrefix + 'Invalid template entry: "' + sid + '"');
			}
		}, this);

		while(df.hasChildNodes() && df.lastChild.localName == "menuseparator")
			df.removeChild(df.lastChild);

		this._undoWindowItems = this._undoTabItems = null;

		mp.textContent = "";
		if(!df.hasChildNodes()) {
			mp.hidePopup();
			return false;
		}
		mp.appendChild(df);
		return true;
	},
	addUndoTabsList: function(undoPopup) {
        // Based on code from chrome://browser/content/browser.js
        // Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20090824 Minefield/3.7a1pre

        var keys = this.options.accesskeys.closedTabs;
        this._undoTabItems.forEach(function(undoItem, i) {
            var state = undoItem.state;
            var [key, keyPrefix] = this.getKey(keys, i);
            var title = undoItem.title;
            var url = state && state.entries && state.entries[state.index - 1].url || "";
            var mi = this.createElement("menuitem", {
                label: keyPrefix + title,
                accesskey: key,
                class: "menuitem-iconic bookmark-item menuitem-with-favicon",
                oncommand: "this.parentNode.parentNode.undoCloseTabsList.undoCloseTab(" + i + ");",
                cb_url: url,
                cb_urlDecoded: this.convertURI(url),
                cb_closedAt: undoItem.closedAt || 0,
                cb_index: i,
                cb_type: "tab"
            });
            if(
                state
                && "attributes" in state
                && "privateTab-isPrivate" in state.attributes
            ) // https://addons.mozilla.org/addon/private-tab/
                mi.setAttribute("privateTab-isPrivate", "true");
            if(this.cm)
                mi.setAttribute("context", this.cmId);
            var image = undoItem.image // Firefox
                || state && state.attributes && state.attributes.image // SeaMonkey
                || state && state.xultab
                    && /(?:^| )image=(\S+)/.test(state.xultab)
                    && decodeURI(RegExp.$1); // Only Firefox 2.0 ?
            if(image)
                mi.setAttribute("image", this.cachedIcon(image));
            if(i == 0)
                mi.setAttribute("key", "key_undoCloseTab");
            undoPopup.appendChild(mi);
        }, this);
    },
    getKey: function(keys, i) {
        var key = keys && keys.charAt(i % keys.length);
        var keyPrefix = keys && (key + this.options.accesskeyPostfix);
        return [key, keyPrefix];
    },
    checkForMiddleClick: function(e, upd) {
        var mi = e.target;
        if(
            "doCommand" in mi
            && e.button == 1
            && mi.parentNode == e.currentTarget
        ) {
            mi.doCommand();
            if(upd)
                upd();
            else
                this.drawUndoList();
        }
    },
    crop: function(s, crop) {
        if(crop == undefined)
            crop = 500;
        if(s.length <= crop)
            return s;
        var start = Math.round(crop*0.6);
        return s.substr(0, start) + "…" + s.substr(start - crop);
    },
    convertURI: function(uri, crop) {
        if(!uri || uri.indexOf("\n") != -1)
            return uri;
        try {
            uri = "losslessDecodeURI" in window
                ? losslessDecodeURI(makeURI(uri))
                : decodeURI(uri);
        }
        catch(e) {
            Components.utils.reportError(e);
        }
        return this.crop(uri, crop);
    },
    cachedIcon: function(src) {
        src = src.replace(/[&#]-moz-resolution=\d+,\d+$/, ""); // Firefox 22+
        if(
            !/^https?:/.test(src)
            // IDN, see https://bugzilla.mozilla.org/show_bug.cgi?id=311045
            || /^https?:\/\/[^.:\/]+\.[^a-z0-9-]+(?:\/|$)/.test(src)
            || this.appName == "SeaMonkey" && this.appVersion <= 2
            || this.appName == "Firefox"   && this.appVersion <= 3.5
        )
            return src;
        return "moz-anno:favicon:" + src; // https://bugzilla.mozilla.org/show_bug.cgi?id=467828
    },
    updUI: function() {
        var tabsCount = this.closedTabCount;
        var dis = !tabsCount 
        if(
            dis
            
            && this.options.menuTemplate.indexOf("restoreLastSession") != -1
            && "restoreLastSession" in this.ss && this.ss.canRestoreLastSession
        )
            dis = false;
        this.button.disabled = dis;
    },
    updTooltip: function(tip, tn) {
		var template, header, title, url, closedAt;
		if(tn == this.button) {
			template = this.options.buttonTipTemplate;
			header = _localize("restoreTab");
			let undoTabItems = JSON.parse(this.ss.getClosedTabData(window));
			if(undoTabItems.length) {
				let lastItem = undoTabItems[0];
				title = lastItem.title;
				url = lastItem.state && lastItem.state.entries
					&& lastItem.state.entries[lastItem.state.index - 1].url;
				closedAt = lastItem.closedAt || 0;
			}
		}
        else if(tn.hasAttribute("cb_index")) {
            template = this.options.itemTipTemplate;
            title = tn.getAttribute("label");
            url = tn.getAttribute("cb_url");
            closedAt = +tn.getAttribute("cb_closedAt");
        }
        else {
            return false;
        }

        var tipData = this.getTooltipData(template, header, title, url, closedAt);
        tip.textContent = "";
        tip.appendChild(tipData);
        if(closedAt && template.indexOf("closedAt") != -1) {
            tip.initUpdateTimer(function() {
                var tipData = this.getTooltipData(template, header, title, url, closedAt);
                if(tipData.textContent != tip.textContent) {
                    tip.textContent = "";
                    tip.appendChild(tipData);
                }
            }, this);
        }
        return tip.hasChildNodes();
    },
    getTooltipData: function(template, header, title, url, closedAt) {
        var df = document.createDocumentFragment();
        var hasHeader = header && template.indexOf("header") != -1;
        function item(key, val) {
            var lbl = document.createElementNS(xulns, "label");
            lbl.className = "cb-" + key;
            //lbl.setAttribute("value", val);
            lbl.textContent = val;
            lbl.setAttribute("maxwidth", "450"); // Trick to restore right border for long lines
            if(key == "closedAt" || hasHeader && key != "header")
                lbl.style.color = "grayText";
            return df.appendChild(lbl);
        }
        template.forEach(function(key) {
            switch(key) {
                case "header":
                    if(header)
                        item(key, header);
                break;
                case "title":
                    if(title && title != url)
                        item(key, title);
                break;
                case "url":
                    if(url)
                        item(key, this.convertURI(url));
                break;
                case "closedAt":
                    if(!closedAt)
                        break;
                    let dt = Math.round(Math.max(0, Date.now() - closedAt)/1000);
                    let days = Math.floor(dt/24/3600);
                    dt -= days*24*3600;
                    let d = new Date((dt + new Date(dt).getTimezoneOffset()*60)*1000);
                    let m = d.getMinutes();
                    let ts = d.getHours() + ":" + (m > 9 ? m : "0" + m);
                    if(days)
                        ts = days + _localize("day") + " " + ts;
                    let tsTip = _localize("itemTip")
                        .replace("%ago", ts)
                        .replace("%date", new Date(closedAt).toLocaleString());
                    item(key, tsTip);
            }
        }, this);
        return df;
    },
    get wm() {
        delete this.wm;
        return this.wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
            .getService(Components.interfaces.nsIWindowMediator);
    },
    updUIGlobal: function() {
        var isSeaMonkey = this.appName == "SeaMonkey";
        var ws = this.wm.getEnumerator(isSeaMonkey ? null : "navigator:browser");
        const id = this.button.id;
        while(ws.hasMoreElements()) {
            let win = ws.getNext();
            if(!isSeaMonkey || this.isBrowserWindow(win)) {
                let btn = win.document.getElementById(id);
                if(btn && "undoCloseTabsList" in btn) {
                    let ucl = btn.undoCloseTabsList;
                    ucl.ensureSessionsInitialized(ucl.updUI, ucl);
                }
            }
        }
    },
    isBrowserWindow: function(win) {
        var loc = window.location.href;
        return loc == "chrome://browser/content/browser.xul"
            || loc == "chrome://navigator/content/navigator.xul";
    },
    ensureSessionsInitialized: function(callback, context) {
        var _this = this;
        var stopTime = Date.now() + 3e3;
        (function ensureInitialized() {
            try {
                _this.ss.getClosedTabCount(window);
                callback.call(context);
                return;
            }
            catch(e) {
                if(Date.now() > stopTime) {
                    Components.utils.reportError(
                        _this.errPrefix
                        + "Can't initialize: nsISessionStore.getClosedTabCount() failed"
                    );
                    Components.utils.reportError(e);
                    return;
                }
            }
            setTimeout(ensureInitialized, 50);
        })();
    }
};

if(!this.undoCloseTabsList.options.useMenu && this.undoCloseTabsList.useCentextMenu) {
    this.oncontextmenu = function(e) {
        if(
            e.target != this
            || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey
            || !this.undoCloseTabsList.mp.hasChildNodes()
        )
            return;
        e.preventDefault();
        this.undoCloseTabsList.showMenu(e); // Show menu without "context" flag
    };
}
if(this.undoCloseTabsList.options.rightClickToUndoCloseTab) {
    this.oncontextmenu = function(e) {
        if(e.target == this && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey)
            e.preventDefault();
    };
}

this.disabled = true;
setTimeout(function(_this) {
    _this.undoCloseTabsList.init();
}, 0, this);

//===================
// Styles
// Used icons from Undo Closed Tabs Button extension

// Styles can't override hardcoded icon
if( // Remove icon only if nsIStyleSheetService works on-the-fly (Firefox 3.0+)
    !Components.ID("{41d979dc-ea03-4235-86ff-1e3c090c5630}")
        .equals(Components.interfaces.nsIStyleSheetService)
) {
    let icon = this.icon
        || this.ownerDocument.getAnonymousElementByAttribute(this, "class", "toolbarbutton-icon");
    if(icon)
        icon.src = "";
    else
        this.image = "";
}

var cssStr = '\
    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");\n\
    @-moz-document url("%windowURL%") {\n\
        %button% {\n\
            list-style-image: url("data:image/png;base64,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") !important;\n\
            -moz-image-region: rect(0, 24px, 24px, 0) !important;\n\
        }\n\
        %button%:hover {\n\
            -moz-image-region: rect(0, 48px, 24px, 24px) !important;\n\
        }\n\
        %button%[disabled="true"] {\n\
            -moz-image-region: rect(0, 72px, 24px, 48px) !important;\n\
        }\n\
        toolbar[iconsize="small"] %button% {\n\
            -moz-image-region: rect(24px, 16px, 40px, 0) !important;\n\
        }\n\
        toolbar[iconsize="small"] %button%:hover {\n\
            -moz-image-region: rect(24px, 32px, 40px, 16px) !important;\n\
        }\n\
        toolbar[iconsize="small"] %button%[disabled="true"] {\n\
            -moz-image-region: rect(24px, 48px, 40px, 32px) !important;\n\
        }\n\
    }'
    .replace(/%windowURL%/g, window.location.href)
    .replace(/%button%/g, "#" + this.id);
var cssURI = this.cssURI = Components.classes["@mozilla.org/network/io-service;1"]
    .getService(Components.interfaces.nsIIOService)
    .newURI("data:text/css," + encodeURIComponent(cssStr), null, null);
var sss = this.sss = Components.classes["@mozilla.org/content/style-sheet-service;1"]
    .getService(Components.interfaces.nsIStyleSheetService);
if(!sss.sheetRegistered(cssURI, sss.USER_SHEET))
    sss.loadAndRegisterSheet(cssURI, sss.USER_SHEET);


this.onDestroy = function(reason) {
    this.undoCloseTabsList.destroy();
    if(reason == "update" || reason == "delete") {
        let sss = this.sss;
        let cssURI = this.cssURI;
        if(sss.sheetRegistered(cssURI, sss.USER_SHEET))
            sss.unregisterSheet(cssURI, sss.USER_SHEET);
    }
};
if(this.undoCloseTabsList.options.useMenu) {
    this.type = "menu";
    this.orient = "horizontal";
}
setTimeout(() => this.undoCloseTabsList.updUI(), 250);
var style = custombutton.buttonGetHelp(self).replace(/id/g, _id);
var uri = makeURI('data:text/css,'+ encodeURIComponent(style));
var sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
sss.loadAndRegisterSheet(uri, 0); 

addEventListener("contextmenu", e => !this.disabled || e.ctrlKey || e.shiftKey || e.preventDefault(), false, this);

Хотя бы это заменить ? gBrowser.removeAllTabsBut(gBrowser.selectedTab)

Отредактировано ВВП (02-12-2022 15:28:38)

Отсутствует

 

№1663611-12-2022 20:14:20

pnm4
Участник
 
Группа: Members
Зарегистрирован: 11-12-2022
Сообщений: 2
UA: Firefox 108.0

Re: Custom Buttons

Извините, здесь немного дилетанта, также использую Google Translate.
Я просто хочу получить выделенный текст и найти его. Этот код по-прежнему работает на страницах «about:», но не на веб-сайтах.

Выделить код

Код:

function getSelectedText() {
  var string = document.commandDispatcher.focusedWindow.getSelection().toString();
  return string;
}
this.Search = function(aEvent) {
var query = getSelectedText();
alert("Query: "+query);
}
this.Search(event);

Что мне нужно сделать, чтобы получить текущий выбор в Firefox 100+?

Отсутствует

 

№1663712-12-2022 12:46:16

brake
Участник
 
Группа: Members
Зарегистрирован: 05-05-2022
Сообщений: 14
UA: Firefox 108.0

Re: Custom Buttons

pnm4 пишет

Извините, здесь немного дилетанта, также использую Google Translate.
Я просто хочу получить выделенный текст и найти его. Этот код по-прежнему работает на страницах «about:», но не на веб-сайтах.

Выделить код

Код:

function getSelectedText() {
  var string = document.commandDispatcher.focusedWindow.getSelection().toString();
  return string;
}
this.Search = function(aEvent) {
var query = getSelectedText();
alert("Query: "+query);
}
this.Search(event);

Что мне нужно сделать, чтобы получить текущий выбор в Firefox 100+?

Выделить код

Код:

gBrowser.selectedBrowser.finder.getInitialSelection().then((r) => {
    if (r.selectedText) {
        console.log(r.selectedText)
    }
})

Отсутствует

 

№1663812-12-2022 15:47:12

Dumby
Участник
 
Группа: Members
Зарегистрирован: 12-08-2012
Сообщений: 2259
UA: Firefox 78.0

Re: Custom Buttons

ВВП пишет

undoclose кнопка сдохла,рихтанул модули session

Это вместо того, чтобы подправить кнопку как здесь (в конце) написано?
Очень странно, если так.

И это placesCmd_undoRemove -воостановить закладку тоже пропало, куда рыть ? Комана работает, пункт не появляется...

Этот код (последний спойлер), вроде, пока ещё работает.


pnm4 пишет

Я просто хочу получить выделенный текст и найти его. Этот код по-прежнему работает на страницах «about:», но не на веб-сайтах.

Выделенного текста здесь нет.
Текст на веб-сайтах находится в другом процессе,
как и на некоторых страницах «about:», например,
таких как about:{newtab, logins, neterror, welcome, protections}


Для получения выделенного текста можно занять clipboard

скрытый текст

Выделить код

Код:

var getSelectedText = async () => {

	var was = gClipboard.read();
	was && gClipboard.write("");

	docShell.doCommand("cmd_copy");
	await new Promise(resolve => setTimeout(resolve, 100));

	var sel = gClipboard.read();
	was && gClipboard.write(was);
	return sel;
}
var search = async () => {
	var query = await getSelectedText();
	alert("Query: " + query);
}
search();


Или использовать код с межпроцессным взаимодействием, но это сложно и неприятно.


Кстати, вариант brake вполне может подойти для поиска.
Однако, следует понимать, что выделенный текст будет «.trim().replace(/\s+/g, " ")»,
и затем обрезан до 150 символов.


Баг 1793463.


Custom Buttons 0.0.7.0.0.28, paxmod и bootstrap в zip-папке.

Отсутствует

 

№1663912-12-2022 19:03:59

ВВП
Участник
 
Группа: Members
Зарегистрирован: 13-03-2021
Сообщений: 337
UA: Firefox 107.0

Re: Custom Buttons

Dumby

Dumby пишет

Это вместо того, чтобы подправить кнопку как здесь (в конце) написано?

Мало...Контекст появился,но вкладки не восстанавливаются !

Отсутствует

 

№1664012-12-2022 23:01:24

pnm4
Участник
 
Группа: Members
Зарегистрирован: 11-12-2022
Сообщений: 2
UA: Firefox 108.0

Re: Custom Buttons

brake пишет
Выделить код

Код:

gBrowser.selectedBrowser.finder.getInitialSelection().then((r) => {
    if (r.selectedText) {
        console.log(r.selectedText)
    }
})

Спасибо!

Отсутствует

 

№1664116-12-2022 16:03:06

Andrey_Krropotkin
Участник
 
Группа: Members
Зарегистрирован: 11-11-2011
Сообщений: 484
UA: Firefox 108.0

Re: Custom Buttons

Dumby проверь, может это только у меня глюк. Установил Custom Buttons 0.0.7.0.0.28, paxmod, версия Лисы 108.0. Такая вот проблема. Если редактировать кнопки, то окно редактирования выскакивает в минимальном размере. Я его растягиваю как мне надо. Размеры окна запоминаются только для редактируемой кнопки. Для следующей кнопки надо повторять опять. Если редактирую во вкладке, то сама Лиса минимизируется. В предыдущих версиях Custom Buttons и Лисы такого не было. Не запомнил когда это выскочило. Сначала обновил Custom Buttons, а потом обновил Лису.   Заранее спасибо

Отсутствует

 

№1664216-12-2022 16:40:24

unter_officer
Участник
 
Группа: Members
Откуда: Санкт-Петербург
Зарегистрирован: 27-03-2011
Сообщений: 605
UA: Firefox 108.0

Re: Custom Buttons

Andrey_Krropotkin пишет

Если редактирую во вкладке, то сама Лиса минимизируется.

У меня в [firefox] 108 такая же хрень.


«The Truth Is Out There»

Отсутствует

 

№1664317-12-2022 14:38:30

Dumby
Участник
 
Группа: Members
Зарегистрирован: 12-08-2012
Сообщений: 2259
UA: Firefox 78.0

Re: Custom Buttons

Andrey_Krropotkin пишет

Если редактировать кнопки, то окно редактирования выскакивает в минимальном размере.
Я его растягиваю как мне надо.
Размеры окна запоминаются только для редактируемой кнопки.
Для следующей кнопки надо повторять опять.

:/ Звучит почти как CB-настройка
[✔] Сохранять размеры и позицию окон редактора отдельно для каждой кнопки

Если редактирую во вкладке, то сама Лиса минимизируется.

Да, вижу. Но это не имеет отношения к расширению.
Во-первых, редактирование во вкладке это не встроенный функционал.


Во-вторых, если, допустим, открывать во вкладке, например, какой-нибудь
chrome://browser/content/preferences/dialogs/fonts.xhtml
то в 107 окно браузера не ресайзится, а в 108 — уже схлоп.
То есть, какую-то общую шнягу завезли, зачем-то.


Вроде помогает добавить в userContent.css

скрытый текст

Выделить код

Код:

@-moz-document url-prefix(chrome://custombuttons/content/editor.xul) {
	:root {
		min-height: 100vh !important;
		min-width: calc(100vw + 18px) !important;
	}
	:root > *, .dialog-button-box {
		margin-right: 18px !important;
	}
}

Отсутствует

 

№1664417-12-2022 15:55:14

unter_officer
Участник
 
Группа: Members
Откуда: Санкт-Петербург
Зарегистрирован: 27-03-2011
Сообщений: 605
UA: Firefox 108.0

Re: Custom Buttons

Dumby пишет

Вроде помогает добавить в userContent.css

скрытый текст

Выделить код

Код:

@-moz-document url-prefix(chrome://custombuttons/content/editor.xul) {
	:root {
		min-height: 100vh !important;
		min-width: calc(100vw + 18px) !important;
	}
	:root > *, .dialog-button-box {
		margin-right: 18px !important;
	}
}

Dumby, большое спасибо!


«The Truth Is Out There»

Отсутствует

 

№1664502-01-2023 22:24:41

Oakwood
Участник
 
Группа: Members
Зарегистрирован: 01-01-2023
Сообщений: 15
UA: Firefox 108.0

Re: Custom Buttons

Очень рад, что CB всё ещё жив на FF108. :cool: Но вот маст-хэв кнопка Autocopy перестала работать, возможно ли её теперь реанимировать? Радость оказалась неполной, т.к. почти все кнопки, которыми постоянно пользовался, отвалились. :| Перечислю их ниже, может, у кого-нибудь найдётся время их починить.


1 - Autocopy: Автоматически копирует выделенный текст на странице, кроме текстовых полей.
Автор: версия bunda1 и версия Dumby

Autocopy - версия работающая на FF64

Выделить код

Код:

/*Initialization Code*/
this.closest("toolbarpaletteitem") || (script => {
    var id = `CB${_id.slice(20)}:Autocopy`, pid = id + "Parent";
    var nsvoStr = `Components.utils.import("resource://gre/modules/Services.jsm", {})`;
    var nsvo = eval(nsvoStr), {Services} = nsvo, parent = nsvo[pid];
    if (!parent) {
        var cid = id + "Child", u = code => "data:," + encodeURIComponent(code);
        var pref = "CB.Autocopy.settings", topic = "quit-application-granted";
        var PREF_ENABLED = 1, PREF_BLINK = 2, PREF_RESET = 4;

        (parent = nsvo[pid] = {
            init() {
                this.readSettings();
                if (!this[PREF_ENABLED]) return;
                this.initChild();
                if (this[PREF_RESET]) this.setObserver(true);
            },
            destroy(reason) {
                var ud = reason[5] == "e";
                if (ud || !this.obsAdded) this.saveSettings();
                delete nsvo[pid];
                if (reason == "delete") Services.prefs.clearUserPref(pref);
                if (!this[PREF_ENABLED]) return;

                this.destroyChild();
                if (ud && this[PREF_RESET]) this.setObserver(false);
            },
            get processURL() {
                delete this.processURL;
                this.frameURL = u(`${nsvoStr}["${cid}"].init(this);`);
                return this.processURL = u(script.replace(/%ID%/g, cid)
                    .replace("%NSVO%", nsvoStr).replace("%BLINK%", this[PREF_BLINK])
                );
            },
            get frameURLDestroy() {
                delete this.frameURLDestroy;
                this.processURLDestroy = u(`${nsvoStr}["${cid}"].forget();`);
                return this.frameURLDestroy = u(`${nsvoStr}["${cid}"].destroy(this);`);
            },
            initChild() {
                Services.ppmm.loadProcessScript(this.processURL, true);
                Services.mm.loadFrameScript(this.frameURL, true);
            },
            destroyChild() {
                Services.mm.removeDelayedFrameScript(this.frameURL);
                Services.mm.loadFrameScript(this.frameURLDestroy, false);
                Services.ppmm.removeDelayedProcessScript(this.processURL);
                Services.ppmm.loadProcessScript(this.processURLDestroy, false);
            },
            readSettings() {
                this.prefVal = Services.prefs.getIntPref(pref, 3);
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    this[setting] = Boolean(this.prefVal & setting);
            },
            saveSettings() {
                var settings = 0;
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    if (this[setting]) settings += setting;
                if (this.prefVal != settings)
                    Services.prefs.setIntPref(pref, settings);
            },
            btns: new Set(),
            register(btn) {
                this.btns.add(btn);
                btn._handleClick = this.click;
                btn.oncontextmenu = this.context;
                this.setImg(btn, this[PREF_ENABLED]);
            },
            unregister(btn, reason) {
                this.btns.delete(btn);
                if (!this.btns.size) this.destroy(reason);
            },
            setImg(btn, state) {
                btn.ownerDocument.getAnonymousElementByAttribute(
                    btn, "class", "toolbarbutton-icon"
                ).src = state
                    ? "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgMBAAQIAAcEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAcACAMEAQEAAAAAAAAAAAAAAAACAwADAAAAABUnAB9cqgC3a7wB4Gq5Ad1qugHearoB3mq6Ad5qugHearoB3mi4AN1qugHgYrMAxR43AC8AAAAAAAEAAAECAAQAAAQAV6AAprP9Vv/W/qn80/+f/9T/ov/U/6L/1P+i/9T/ov/U/6L/1/+n/9X+pfy3/WL/Y7QAvwEAAQAAAAAAFSgAH1ehAKlyzwD1htgf/YzcJ/2K2yP9i9sk/YvbJf2L2yX9i9sm/YnaIv2b4kP92/21/Nf+qv9quwHdBQkACAAAAQBeqwCzr/tR/8X0j/u+8X//vvJ//77ygP++8oD/vvKA/77yf/+98n7/wvSH/4zcKv+e4kv93v+0/2i5AN0DBwAIBQkACGu8AdzV/af/4v/B/d//u//h/7//4f+//+H/v//h/7//4f+//9/+u//n/8n/w/GK/4zaK/3g/7r/aroC3gMHAAgEBwAIarkC3dX/pf/g/sD93v67/9/+vv/g/r//4P6//+D+v//f/r7/3f66/+T/xv/B8Yb/j9st/eT/w/9qugPeAwcACAQHAAhqugLe2v+w/+j/z/3l/8r/5//N/+f/zv/n/87/5//O/+f/zf/l/sj/7P/W/8Xyj/+Q2y/96f/N/2q6A94DBwAIBAcACGq6At7f/7n/7v/c/ev/1v/t/9n/7f/a/+3/2v/t/9r/7f/Z/+r+1f/y/+P/yPKW/5DbMf3s/9X/aroE3gMHAAgEBwAIaroC3uP/wf/z/+j98P/h//L/5P/z/+X/8//l//P/5f/y/+T/8P7g//j/7v/L8p3/kdsy/fD/3P9rugTeAwcACAQHAAhqugLe5v/J//j/8v31/+r/9v/t//f/7v/3/+//9//u//b/7f/0/un//f/4/87yo/+R2zL98f/f/2q5Bd0DBwAIBAcACGq6At7p/8///P/6/fj/8f/6//T/+v/1//r/9f/6//X/+v/0//f+8P//////0fGo/5PbNf30/+f/a7wE3AQJAAgEBwAIabkC3er/0f/+//79+v/0//v/9//8//j//P/4//z/+P/7//f/+f70///////T8qz/i9go+8P9ef9dqwCzAAACAAUJAAhquwHd7f7a//////z+//39/////f////3////9/////f////39/vz9/////dzzvv5v0AD1VqECqRUnAB8AAAAAAQACAGK0AL/J/Yf/8v7k/O3/1//u/9n/7v/Z/+7/2f/u/9n/7v/Z/+3/1//x/eP8vfxu/1WgAKYAAAUAAQIABAABAAAAAAAAHjcALmGzAMVquwLgarkC3Wq6At5qugLearoC3mq6At5qugLearkC3Wu8AeBbqgC3FScAHwAAAAACAwADAAAAAAAAAAAAAAAAAwQCAQQIAAgEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAgABwMDAgAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
                    : "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgEDAAQACAcEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAHCAMBBAEAAAAAAAAAAAAAAAACAAMDAAAAABUAJx9cAKq3awG84GoBud1qAbreagG63moBut5qAbreagG63mgAuN1qAbrgYgCzxR4ANy8AAAAAAAABAAEAAgQABAAAVwCgprNW/f/Wqf7805///9Si///Uov//1KL//9Si///Uov//16f//9Wl/vy3Yv3/YwC0vwEBAAAAAAAAFQAoH1cAoalyAM/1hh/Y/Ywn3P2KI9v9iyTb/Ysl2/2LJdv9iybb/Yki2v2bQ+L927X9/Neq/v9qAbvdBQAJCAABAABeAKuzr1H7/8WP9Pu+f/H/vn/y/76A8v++gPL/voDy/75/8v+9fvL/wof0/4wq3P+eS+L93rT//2gAud0DAAcIBQAJCGsBvNzVp/3/4sH//d+7///hv///4b///+G////hv///4b///9+7/v/nyf//w4rx/4wr2v3guv//agK63gMABwgEAAcIagK53dWl///gwP793rv+/9++/v/gv/7/4L/+/+C//v/fvv7/3br+/+TG///BhvH/jy3b/eTD//9qA7reAwAHCAQABwhqArre2rD//+jP//3lyv//583//+fO///nzv//587//+fN///lyP7/7Nb//8WP8v+QL9v96c3//2oDut4DAAcIBAAHCGoCut7fuf//7tz//evW///t2f//7dr//+3a///t2v//7dn//+rV/v/y4///yJby/5Ax2/3s1f//agS63gMABwgEAAcIagK63uPB///z6P/98OH///Lk///z5f//8+X///Pl///y5P//8OD+//ju///LnfL/kTLb/fDc//9rBLreAwAHCAQABwhqArre5sn///jy//316v//9u3///fu///37///9+7///bt///06f7//fj//86j8v+RMtv98d///2oFud0DAAcIBAAHCGoCut7pz////Pr//fjx///69P//+vX///r1///69f//+vT///fw/v//////0ajx/5M12/305///awS83AQACQgEAAcIaQK53erR///+/v/9+vT///v3///8+P///Pj///z4///79///+fT+///////TrPL/iyjY+8N5/f9dAKuzAAIAAAUACQhqAbvd7dr+//////z+/f/9/////f////3////9/////f////39/P79/////dy+8/5vAND1VgKhqRUAJx8AAAAAAQIAAGIAtL/Jh/3/8uT+/O3X///u2f//7tn//+7Z///u2f//7tn//+3X///x4/38vW78/1UAoKYABQAAAQACBAAAAQAAAAAAHgA3LmEAs8VqArvgagK53WoCut5qArreagK63moCut5qArreagK53WsBvOBbAKq3FQAnHwAAAAACAAMDAAAAAAAAAAAAAAAAAwIEAQQACAgEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAIBwMCAwAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
            },
            click() {
                var newState = parent[PREF_ENABLED] = !parent[PREF_ENABLED];
                for(var btn of parent.btns) parent.setImg(btn, newState);
                newState ? parent.initChild() : parent.destroyChild();
                if (parent[PREF_RESET]) parent.setObserver(newState);
            },
            context(e) {
                if (e.ctrlKey || e.shiftKey) return;
                if (e.detail > 1) return parent.popup.hidePopup();
                if (!this.contains(parent.popup)) this.appendChild(parent.popup);
                e.preventDefault();
                parent.popup.openPopup(this, "after_start");
            },
            get popup() {
                var win = Services.wm.getMostRecentWindow("navigator:browser");
                var doc = win.document, popup = doc.createElement("menupopup");
                popup.setAttribute("onclick", "event.stopPropagation();");
                popup.setAttribute("oncommand", "handleCommand(event.target);");
                for(var [lab, pref] of win.Object.entries({
                    "Выделенный текст мигает при автокопировании": PREF_BLINK,
                    "Выключать автокопирование при выходе из браузера": PREF_RESET
                })) {
                    var menuitem = popup.appendChild(doc.createElement("menuitem"));
                    menuitem.setAttribute("label", lab);
                    menuitem.setAttribute("type", "checkbox");
                    if (this[menuitem.pref = pref]) menuitem.setAttribute("checked", true);
                }
                popup.handleCommand = menuitem => {
                    var newState = this[menuitem.pref] = menuitem.hasAttribute("checked");
                    if (!this[PREF_ENABLED]) return;

                    if (menuitem.pref == PREF_BLINK)
                        Services.ppmm.broadcastAsyncMessage(cid + ":FromParent", {blink: newState});
                    else if (menuitem.pref == PREF_RESET)
                        this.setObserver(newState);
                }
                delete this.popup; return this.popup = popup;
            },
            obsAdded: false,
            setObserver(set) {this.obsAdded = set
                ? Services.obs.addObserver(this, topic, false)
                : Services.obs.removeObserver(this, topic);
            },
            observe() {
                Services.obs.removeObserver(this, topic);
                this[PREF_ENABLED] = false;
                this.saveSettings();
            }
        }).init();
    }
    parent.register(this);
    addDestructor(reason => parent.unregister(this, reason), parent);

})(`(nsvo => (nsvo["%ID%"] = {
    x: -1, y: -1, d: false,
        handleEvent(e) {
        if (e.type[0] == "m") return e.button || this[e.type](e);
        else if (e.button != 1) return;

        var ed = e.target.editor;
        if (
            ed && ed instanceof Ci.nsIEditor && !ed.selection.isCollapsed
            && ed.canPaste(ed.selectionController.SELECTION_NORMAL)
        )
            e.preventDefault(),
            ed.paste(ed.selectionController.SELECTION_NORMAL);
    },
    mousedown(e) {this.x = e.screenX; this.y = e.screenY, this.down = true;},
    mouseup(e) {
        var {down} = this; this.down = false; if (!down) return;
        if (e.screenX == this.x && e.screenY == this.y && (e.detail == 1 || e.target.matches(
            "textarea[disabled],input[disabled],button,select,summary"
        )))
            return;
        var name = e.originalTarget.nodeName;
        if (/^(?:(?:xul:)?(?:slider|scrollbarbutton)|resizer)$/.test(name))
            return;
        this.x = this.y = -1;
        var win = this.getFocusedWin(e.target.ownerGlobal);
        var sel = win.getSelection();
        if (sel.toString()) {
            (win.docShell || win.document.docShell).doCommand("cmd_copy", null, win);
            this.blinkEnabled && this.blink(win, e.detail > 1);
        }
    },
    blinkEnabled: %BLINK%,
    blink(win, pause) {
        if (pause) return win.setTimeout(() => this.blink(win), 100);
        var sc = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
            .getInterface(Components.interfaces.nsIWebNavigation)
            .QueryInterface(Components.interfaces.nsIDocShell)
            .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
            .getInterface(Components.interfaces.nsISelectionDisplay)
            .QueryInterface(Components.interfaces.nsISelectionController);
        sc.setDisplaySelection(sc.SELECTION_OFF);
        sc.repaintSelection(sc.SELECTION_NORMAL);
        win.setTimeout(() => {
            sc.setDisplaySelection(sc.SELECTION_ON);
            sc.repaintSelection(sc.SELECTION_NORMAL);
        }, 150);
    },
    getFocusedWin(win) {
        var focusedWin = {};
        var elm = Services.focus.getFocusedElementForWindow(win.top, true, focusedWin);
        return focusedWin.value;
    },
    get cm() {
        delete this.cm;
        return this.cm = Components.classes["@mozilla.org/embedcomp/command-manager;1"]
            .getService(Components.interfaces.nsICommandManager);
    },
    count: 0,
    init(cfmm) {
        this.count += 1;
        cfmm.addEventListener("click", this, true);
        cfmm.addEventListener("mousedown", this);
        cfmm.addEventListener("mouseup", this);
        cfmm.addEventListener("unload", this);
        if (this.count == 1)
            this.cpmm.addMessageListener("%ID%:FromParent", this);
    },
    destroy(cfmm) {
        this.count -= 1;
        cfmm.removeEventListener("click", this, true);
        cfmm.removeEventListener("mousedown", this);
        cfmm.removeEventListener("mouseup", this);
        cfmm.removeEventListener("unload", this);
        if (!this.count)
            this.cpmm.removeMessageListener("%ID%:FromParent", this);
    },
    receiveMessage(msg) {
        if ("blink" in msg.data) this.blinkEnabled = msg.data.blink;
    },
    unload(e) {this.destroy(e.target);},
    forget: () => delete nsvo["%ID%"]

}).cpmm = this)(%NSVO%);`);

addEventListener("click", e => {
    if (e.button != 1) return;
    var ed = e.target.editor;
    if (
        ed && ed instanceof Ci.nsIEditor && !ed.selection.isCollapsed
        && ed.canPaste(ed.selectionController.SELECTION_NORMAL)
    )
        e.preventDefault(),
        ed.paste(ed.selectionController.SELECTION_NORMAL);
}, true);


2 - Auto Activate Tabs: Kод даёт возможность активизировать вкладку наведением курсора немного над вкладкой( 5 пикселей сверху ), без клика. В коде можно изменить высоту наведения.
Автор: Dumby
Auto Activate Tabs - версия работающая на FF64

Выделить код

Код:

/*Initialization Code*/
function tabHover(e) {
    var node = e.target;
    if (
        e.screenY > node.boxObject.screenY + 20 ||
        node.nodeName != "tab" ||
        node == gBrowser.selectedTab
    ) return;
    gBrowser.selectedTab = node;
}
addEventListener("mousemove", tabHover, false, gBrowser.mTabContainer);


3 - Отправить в youtube-dl.exe / yt-dlp.exe: Kод даёт возможность скачивать видео с видео хостингов, в т.ч. с YouTube в максимальном качестве, так же легко как сохранять картинки.
Автор: Dumby
Отправить в youtube-dl.exe / yt-dlp.exe - версия работающая на FF64

Выделить код

Код:

/*Initialization Code*/
(popup => addEventListener("popupshowing", {
    handleEvent(e) {
        if (e.target != popup || this.shouldHide) return;
        var menuitem = document.createElement("menuitem");
        for(var args of Object.entries({
            class: "menuitem-iconic",
            id: "context-sendlinktoytdl",
            label: "Отправить в youtube-dl: MKV",
            oncommand: "linkedObject.oncommand();",
            image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAc0lEQVQ4jWNgGB7gvqdtwANP+y8PvOz/E4Pve9m/v+9pG4AwwMv+PLGakQw5DzcAm4Ifty//f5IQhtcQvAb8/fP1/++Pr/6/bKog3wAY/rBuKWUGfNq5kXwvvO5tJs8LP25f/v80O5G4QKQ4GilOSEMbAAAJoGH0pNGWEwAAAABJRU5ErkJggg=="
        }))
            menuitem.setAttribute(...args);
        menuitem.linkedObject = this;
        popup.insertBefore(menuitem, popup.querySelector("#context-sep-open"));
        addDestructor(() => menuitem.remove());
        this.handleEvent = e => {
            if (e.target == popup) menuitem.hidden = this.shouldHide;
        }
        menuitem.onauxclick = e => {
            e.preventDefault();
            var link = gContextMenu.linkURL;
            var fp = makeFilePicker();
            fp.init(window, null, fp.modeGetFolder);
            fp.open(res => {
                if (res != fp.returnOK) return;
                fp.file.append("%(title)s.%(ext)s");
                this.oncommand(fp.file.path, link);
            });
        }
    },
    get shouldHide() {
        return !(gContextMenu.onLink || gContextMenu.onPlainTextLink)
            || !/^https?:\/\//.test(gContextMenu.linkURL);
    },
    args: ["--no-check-certificate", "--no-call-home", "-o"],
    oncommand(path = String.raw`D:\YouTube\%(title)s(%(uploader)s)%(id)s.%(ext)s`, link = gContextMenu.linkURL) {

        var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
        process.init(FileUtils.File(String.raw`D:\YouTube\youtube-dl.exe`));

        var args = this.args.concat(path, link);
        process.runwAsync(args, args.length);
    }
}, false, popup || 1))(document.getElementById("contentAreaContextMenu"));


4 - Save Picture On Double Click: Сохранение изображений по двойному клику ПКМ без запроса.
Кнопка работает, но запрашивает место сохранения и имя файла.
Автор: Dumby
Save Picture On Double Click - версия работающая на FF64

Выделить код

Код:

/*Initialization Code*/
addEventListener("contextmenu", {
    handleEvent(e) {
        if (e.detail != 2 || !gContextMenu || !gContextMenu.onImage) return;

        var pl = "browser.download.folderList";
        var pu = "browser.download.useDownloadDir";

        var cl = Services.prefs.getIntPref(pl), sl = cl == 2;
        var cu = Services.prefs.getBoolPref(pu);

        sl || Services.prefs.setIntPref(pl, 2);
        cu || Services.prefs.setBoolPref(pu, true);
        try {
            this.save(); e.preventDefault(); this.hide();
        } finally {
            sl || Services.prefs.setIntPref(pl, cl);
            cu || Services.prefs.setBoolPref(pu, cu);
        }
    },
    get hide() {
        delete this.hide;
        var popup = document.getElementById("contentAreaContextMenu");
        return this.hide = popup.hidePopup.bind(popup);
    },
    get save() {
        var func = eval(gContextMenu.saveMedia.toSource()
            .replace(/(false,\s+)false,/, "$1true,")
            .replace(/^s/, "0,function s")
        );
        delete this.save;
        return this.save = () => func.call(gContextMenu);
    }
}, false, gBrowser.tabpanels || gBrowser.mPanelContainer || 1);


5 - Reload Tab On Click: Жмём ПКМ по любой вкладке и всегда при возврате к ней получаем актуальную информацию, т.к. вкладка автоматически обновляется.
Автор: Dumby
Reload Tab On Click - версия работающая на FF64

Выделить код

Код:

/*Initialization Code*/
function reloader(e) {
    var tab = e.target;
    var br = tab.linkedBrowser;

    gBrowser.reloadTab(tab);
    br.addEventListener("DOMContentLoaded", function onLoad(e) {
        br.removeEventListener("DOMContentLoaded", onLoad, false);
        e.target.defaultView.scroll(0, 0);
    }, false);
}
function addListener(e) {
    if (e.button != 2 || e.target.nodeName != "tab") return;
    e.preventDefault();
    var tab = e.target;
    if (!tab.reloader) {
        addEventListener("TabSelect", reloader, false, e.target);
        tab.reloader = true;
        return;
    }
    removeEventListener("TabSelect", reloader, false, e.target);
    delete tab.reloader;
}
addEventListener("click", addListener, false, gBrowser.mTabContainer);

Отредактировано Oakwood (05-01-2023 11:48:34)

Отсутствует

 

№1664606-01-2023 15:02:25

ВВП
Участник
 
Группа: Members
Зарегистрирован: 13-03-2021
Сообщений: 337
UA: Firefox 107.0

Re: Custom Buttons

Oakwood

Oakwood пишет

Отправить в youtube-dl.exe / yt-dlp.exe - версия работающая на FF64

Не актуально...Yt downloader , или просто плеер смотреть...Типа, var path = "D:\\PotPlayer\\PotPlayerMini64.exe";

Выделить код

Код:

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%0A%20%20%3Cimage%3E%3C%21%5BCDATA%5Bdata%3Aimage/x-icon%3Bbase64%2CAAABAAEAFBQAAAEAIAC4BgAAFgAAACgAAAAUAAAAKAAAAAEAIAAAAAAAkAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMTExADExMW4xMTPCMjIxxjU1K8Y1NSfGNjYnxzY2Jsc2NibHNjYmxzY2J8c1NSrHMzMwxzIyNccyMjLGMzMyxjIyMsYxMTHCMjIybjMzMwAyMjFbMTEy/yYmWPgJCcP8AADe/AAA3vwAAOf8AADs/AAA6/wAAOr8AADq/AAA7PwAAOr8AADi/AUF0/wFBdP8HBx8/DQ0KvwyMjL/MjIyWzExNKQzMyz8CQm8+wAA8f4AAN7+AADe/AAA5/wAAOz8AADr/AAA6vwAAOr8AADs/AAA6vwAAOL8BQXT/AUF0/wAAN//KytJ/jIyMvwxMTGkMjIyozIyMP4BAdX7AADg/wEB3v8AAN7+AQHf/gAA3P8qKuL/RUXl/0VF5f8AANv/AgLe/wAA3v8AAOf/AADn/wAA5f8hIWr/MjIy/jIyMqMyMjKjMjIw/gEB1fsAAOD/AQHe/wAA3v4BAd/+AADc/yoq4v9FReX/RUXl/wAA2/8CAt7/AADe/wAA5/8AAOf/AADl/yEhav8yMjL+MjIyozQ0LKMyMjD+AQHV+wAA4P8BAd7/AQHe/wAA3/8JCd//9fX8////////////Ly/k/wAA3v8BAd//AADd/wAA3f8AAOX/ISFq/zMzM/8yMjKjNTUqpC0tQf8BAdX7AADg/wEB3v8BAd7/AADf/wkJ3//19fz///////////8vL+T/AADe/wEB3/8AAN3/AADd/wAA5f8eHnf/MTEx/zIyMqQ0NCmkKytH/wAA3/sAAOH+AgLe/wIC3v8AAN3/nJzy//X1/P///////////9bW+P8PD+D/AADe/wEB3v8BAd7/AADo/xoaef88PDz/Li4upDU1KaQrK0n/AADi+wEB4P8AAN3/////////////////////////////////////////////////AQHd/wEB3f8AAOr/Gxt6/zU1Nf8xMTGkNDQqpCsrSf8AAOL7AADg/wAA3v////////////////////////////////////////////////8AANz/AADc/wAA6v8eHnb/MDAw/zIyMqQ0NC2jLCxG/wAA3vsAAOH+AQHf/wEB3/8AAN3/CAjf//X1/P///////////0xM5/8AANv/AADf/wAA3v8AAN7/AADp/yEhaP81NTX/MDAwozIyNKQuLj//AgLT+wAA4f8BAd7/AQHe/wIC3v8YGOD/9fX8////////////XFzp/wMD3f8CAt//AADd/wAA3f8AAOX/ISFo/zw8PP4uLi6kMTE0oTMzLf4CAtP7AADh/wEB3v8BAd7/AgLe/xgY4P/19fz///////////9cXOn/AwPd/wIC3/8AAN3/AADd/wAA5f8qKkH/MTEx/jIyMqExMTShMzMt/gIC0/sAAOH/AQHe/wEB3v8CAt7/GBjg//X1/P///////////1xc6f8DA93/AgLf/wAA3f8AAN3/AADl/yoqQf8xMTH+MjIyoTExMUszMy3+Cwuz+wAA8/4EBNH7BATR+wEB2fsAANz8AADa/gAA2P8AANj/AADb/QEB2vsCAtT7AADq/wAA6v8BAdv/NDQq+zIyMv8yMjJLMDAwADExM/8qKkr3DQ20+wQE0fsEBNH7AQHZ+wAA3PwAANr+AADY/wAA2P8AANv9AQHa+wIC1PsHB8f7BwfH+yAgbfszMzOOMjIyTTIyMgAvLy8AMjIxTTExM8IyMjHGNTUrxjU1J8Y2NifHNjYmxzY2Jsc2NibHNjYnxzU1KsczMzDHMjI1xzIyMsYzMzLGMjIyxjExMcIyMjIAMzMzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///wAP//8ACAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAEACAADAAwAAwAP//8AA%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*/%0A%28func%20%3D%3E%20%7B%0A%09var%20sysPlayerName%20%3D%20%22YTDownloader%22%3B%0A%09var%20path%20%3D%20%22D%3A%5C%5CYT%20Downloader%20Portable%5C%5CYTDownloaderPortable.exe%22%3B%0A%09var%20videoMoved%20%3D%20%22%u0412%u0438%u0434%u0435%u043E%20%u043F%u0435%u0440%u0435%u043D%u0435%u0441%u0435%u043D%u043E%20%u0432%20%22%20+%20sysPlayerName%3B%0A%09var%20noFound%20%3D%20%22%u041D%u0435%20%u043D%u0430%u0439%u0434%u0435%u043D%u043E%20%u0432%u0438%u0434%u0435%u043E%20%u043D%u0430%20%u0441%u0442%u0440%u0430%u043D%u0438%u0446%u0435%2C%20%u0434%u043E%u0441%u0442%u0443%u043F%u043D%u043E%u0435%20%u0434%u043B%u044F%20%u043F%u0435%u0440%u0435%u043D%u043E%u0441%u0430%20%u0432%20%22%20+%20sysPlayerName%3B%0A%0A%09%0A%09this.label%20%3D%20%22%u041E%u0442%u043A%u0440%u044B%u0442%u044C%20%u0432%u0438%u0434%u0435%u043E%20%u0432%20%22%20+%20sysPlayerName%3B%0A%09this.tooltipText%20%3D%20%22%u041B%3A%20%u0421%u043A%u0430%u0447%u0430%u0442%u044C%20%u0441%20YTDownloader%5Cn%u041F%3A%20%u0421%u043A%u0430%u0447%u0430%u0442%u044C%20%u0438%u0437%20Clipboard%22%3B%0A%0A%09this._handleClick%20%3D%20%28%29%20%3D%3E%20%7B%0A%09%09var%20msgName%20%3D%20_id%20+%20%22%3APlayer%22%3B%0A%09%09var%20listener%20%3D%20%28%7Bdata%7D%29%20%3D%3E%20data%20%3F%20run%28%5Bdata%5D%29%20%3A%20notify%28%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20listener%20%3D%20%28%7Bdata%7D%29%20%3D%3E%20data%20%3F%20run%28%5Bdata%5D%2C%20true%29%20%3A%20notify%28%29%3B%0A%09%09messageManager.addMessageListener%28msgName%2C%20listener%29%3B%0A%09%09addDestructor%28%28%29%20%3D%3E%20messageManager.removeMessageListener%28msgName%2C%20listener%29%29%3B%0A%0A%09%09var%20url%20%3D%20%22data%3Acharset%3Dutf-8%2C%22%20+%20encodeURIComponent%28%0A%09%09%09%60%28%24%7Bfunc%7D%29%28%29%60.replace%28%22MSG_NAME%22%2C%20msgName%29%0A%09%09%09%09.replace%28%22VIDEO_MOVED%22%2C%20encodeURIComponent%28videoMoved%29%29%0A%09%09%09%09.replace%28%22CONFIRM%22%2C%20encodeURIComponent%28%22%20%20%20%20%20%20%20%20%20%20%20%u041E%u0442%u043A%u0440%u044B%u0442%u044C%20%u0441%u0441%u044B%u043B%u043A%u0443%20%u0432%20YTDownloader%20%3F%22%29%29%0A%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%09%09%29%3B%0A%09%09%28this._handleClick%20%3D%20%28%29%20%3D%3E%20gBrowser.selectedBrowser.messageManager.loadFrameScript%28url%2C%20false%29%29%28%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%09%7D%0A%09this.onclick%20%3D%20e%20%3D%3E%20e.button%20%21%3D%201%20%7C%7C%20gShowPopup%28this%29%3B%20%0A%09this.oncontextmenu%20%3D%20e%20%3D%3E%20%7B%0A%09%09if%20%28e.ctrlKey%20%7C%7C%20e.shiftKey%20%7C%7C%20e.altKey%29%20return%3B%0A%09%09e.preventDefault%28%29%3B%0A%09%09if%20%28custombuttons.confirmBox%28null%2C%22%20%20%20%20%20%20%u0417%u0430%u043F%u0443%u0441%u0442%u0438%u0442%u044C%20%20%u0438%u0437%20%u0431%u0443%u0444%u0435%u0440%u0430%20%u043E%u0431%u043C%u0435%u043D%u0430%20%3F%20%20%22%2C%20%22%u0414%u0430%22%2C%20%22%u041E%u0442%u043C%u0435%u043D%u0430%22%29%20%29%20%7B%20%20%20%20%20%20%20%20%0A%09%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20run%28%5BgClipboard.read%28%29%5D%29%3B%0A%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%09%0A%7D%3B%0A%09var%20popup%20%3D%20document.getElementById%28%22contentAreaContextMenu%22%29%3B%0A%09addEventListener%28%22popupshowing%22%2C%20%7B%0A%09%09get%20hidden%28%29%20%7B%0A%09%09%09return%20%21%28gContextMenu.onLink%20%7C%7C%20gContextMenu.onVideo%20%7C%7C%20gContextMenu.onPlainTextLink%29%3B%0A%09%09%7D%2C%0A%09%09handleEvent%28%29%20%7B%0A%09%09%09if%20%28this.hidden%29%20return%3B%0A%09%09%09var%20menuitem%20%3D%20document.createXULElement%28%22menuitem%22%29%3B%0A%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%09%09%09for%28var%20args%20of%20Object.entries%28%7B%0A%09%09%09%09image%3A%20self.image%2C%0A%09%09%09%09%0A%09%09%09%09oncommand%3A%20%22play%28%29%3B%22%2C%0A%09%09%09%09class%3A%20%22menuitem-iconic%22%2C%0A%09%09%09%09label%3A%20%22%u041E%u0442%u043A%u0440%u044B%u0442%u044C%20%u0432%20%22%20+%20sysPlayerName%0A%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%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%09%09%09%7D%29%29%0A%09%09%09%09menuitem.setAttribute%28...args%29%3B%0A%09%09%09menuitem.play%20%3D%20%28%29%20%3D%3E%20play%28gContextMenu.linkURL%20%7C%7C%20gContextMenu.mediaURL%29%3B%0A%09%09%09document.getElementById%28%22context-savelink%22%29.before%28menuitem%29%3B%0A%09%09%09addDestructor%28%28%29%20%3D%3E%20menuitem.remove%28%29%29%3B%0A%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%09%09%09this.handleEvent%20%3D%20e%20%3D%3E%20%7B%0A%09%09%09%09if%20%28e.target%20%3D%3D%20popup%29%20menuitem.hidden%20%3D%20this.hidden%3B%0A%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%09%09%09%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%09%09%7D%0A%09%7D%2C%20false%2C%20popup%20%7C%7C%201%29%3B%0A%0A%09var%20play%20%3D%20link%20%3D%3E%20custombuttons.confirmBox%28null%2C%22%20%20%20%20%20%20%20%20%20%u041E%u0442%u043A%u0440%u044B%u0442%u044C%20%u0441%u0441%u044B%u043B%u043A%u0443%20%u0432%20YTDownloader%20%3F%22%2C%20%22%u0414%u0430%22%2C%20%22%u041E%u0442%u043C%u0435%u043D%u0430%22%29%20%26%26%20run%28%5Blink%5D%29%3B%0A%0A%0A%09var%20run%20%3D%20%28...a%29%20%3D%3E%20%7B%0A%09%09var%20file%20%3D%20FileUtils.File%28path%29%3B%0A%09%09%28run%20%3D%20%28args%2C%20quit%29%20%3D%3E%20%7B%0A%09%09%09if%20%28%21file.exists%28%29%29%20return%20custombuttons.alertBox%28%22File%20not%20exists%21%22%2C%20path%29%3B%0A%09%09%09var%20process%20%3D%20Cc%5B%22@mozilla.org/process/util%3B1%22%5D.createInstance%28Ci.nsIProcess%29%3B%0A%09%09%09process.init%28file%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%09%09%09process.runwAsync%28args%2C%20args.length%29%3B%0A%09%09%09%0A%09%09%7D%29%28...a%29%3B%0A%09%7D%0A%09var%20notify%20%3D%20%28%29%20%3D%3E%20%7B%0A%09%09var%20name%20%3D%20_id%20+%20%22-noFound%22%3B%0A%09%09var%20as%20%3D%20Cc%5B%22@mozilla.org/alerts-service%3B1%22%5D.getService%28Ci.nsIAlertsService%29%3B%0A%09%09%28notify%20%3D%20%28%29%20%3D%3E%20setTimeout%28as.closeAlert%2C%201150%2C%20name%2C%20as.showAlertNotification%28%0A%09%09%09%22chrome%3A//global/skin/icons/question-48.png%22%2C%20%22%22%2C%20noFound%2C%20false%2C%20%22%22%2C%20null%2C%20name%0A%09%09%29%29%29%28%29%3B%0A%09%7D%0A%0A%7D%29%28%28%29%20%3D%3E%20%7B%0A%0A%09var%20found%2C%20videoMoved%2C%20SEND%20%3D%20msg%20%3D%3E%20%7B%0A%09%09found%20%3D%20true%3B%0A%09%09if%20%28%21msg%20%7C%7C%20Cc%5B%22@mozilla.org/embedcomp/prompt-service%3B1%22%5D%0A%09%09%09.getService%28Ci.nsIPromptService%29%0A%09%09%09.confirm%28content%2C%20null%2C%20decodeURIComponent%28%22CONFIRM%22%29%29%0A%09%09%29%20%7B%0A%09%09%09if%20%28msg%29%20videoMoved%20%3D%20decodeURIComponent%28%22VIDEO_MOVED%22%29%3B%0A%09%09%09sendAsyncMessage%28%22MSG_NAME%22%2C%20msg%29%3B%0A%09%09%7D%0A%09%09else%20return%20true%3B%0A%09%7D%0A%0A%09var%20YoutubeID%20%3D%20/%28%3F%3Ayoutube%28%3F%3A-nocookie%29%3F%5C.com%5C/%28%3F%3A%5B%5E%5C/%5Cn%5Cs%5D+%5C/%5CS+%5C/%7C%28%3F%3Av%7Ce%28%3F%3Ambed%29%3F%29%5C/%7C%5CS*%3F%5B%3F%26%5Dv%3D%29%7Cyoutu%5C.be%5C/%29%28%5Ba-zA-Z0-9_-%5D%7B11%7D%29%28%3F%3A%5CW%7C%24%29/%3B%0A%0A%09var%20tmp%20%3D%20%27%27%2C%0A%09tmpp%20%3D%20%27%27%2C%0A%09innerA%20%3D%20%27%3Cdiv%20style%3D%22display%3Ablock%21important%3Bcolor%3A%2300ff00%21important%3Bwidth%3A250px%21important%3Bfont%3Abold%2016px%20serif%21important%3Bz-index%3A999%21important%3Bopacity%3A1%21important%3Bvisibility%3A%20visible%21important%3B%27%2C%0A%09innerB%20%3D%20%27left%3A5px%21important%3Bposition%3Aabsolute%21important%3Bheight%3Aauto%21important%3Bbox-sizing%3Aborder-box%21important%3Bpadding%3A5px%21important%3Bmargin%3A5px%21important%3B%27%2C%0A%09//stopPl%20%3D%20%22javascript%3A%28function%28%29%7Bv%3Ddocument.getElementById%28%27movie_player%27%29%3Bif%28v%29%7Bv.stopVideo%28%29%7Delse%7Bv%3Ddocument.getElementsByTagName%28%27video%27%29%3Bif%28v%29%7Bv%5B0%5D.src%3D%27%27%3Btry%7Bv%5B0%5D.load%28%29%7Dcatch%28e%29%7B%7D%7D%3B%7D%7D%29%28%29%3B%22%2C%0A%09ytIMGouter%20%3D%20function%20%28ytID%29%20%7B%0A%09%09return%20%27%3Cdiv%20width%3D%22100%25%22%3E%3Cbr%20/%3E%3Ca%20target%3D%22_blank%22%20href%3D%22https%3A//www.youtube.com/watch%3Fv%3D%27%20+%20ytID%20+%20%27%22%3E%3Cimg%20src%3D%22https%3A//i.ytimg.com/vi/%27%20+%20ytID%20+%20%27/hqdefault.jpg%22%3E%3C/a%3E%3Cbr%20/%3E%27%20+%20innerA%20+%20%27background-color%3Ablack%21important%3Bposition%3Arelative%21important%3Bbottom%3A20px%21important%3B%22%3E%26nbsp%3B%26nbsp%3B%27%20+%20videoMoved%20+%20%27%3C/div%3E%3Cbr%20/%3E%3C/div%3E%3Cbr%20/%3E%27%0A%09%7D%2C%0A%09handlWin%20%3D%20function%20%28currentWin%29%20%7B%0A%09%09tmp%20%3D%20%27%27%3B%0A%09%09var%20elem%20%3D%20currentWin.document.getElementsByTagName%28%27video%27%29%2C%0A%09%09currLoc%20%3D%20currentWin.location%3B%0A%09%09if%20%28elem.length%20%3E%200%29%20%7B%0A%09%09%09if%20%28currLoc.hostname.indexOf%28%27youtu%27%29%20%21%3D%20-1%20%26%26%20%28tmp%20%3D%20currLoc.toString%28%29.match%28YoutubeID%29%29%20%26%26%20tmp%5B1%5D.length%20%3D%3D%2011%29%20%7B%0A%0A%09%09%09%09if%20%28SEND%28%27https%3A//www.youtube.com/watch%3Fv%3D%27%20+%20tmp%5B1%5D%29%29%20return%3B%0A%0A%09%09%09%09videoMovedbox%20%3D%20currentWin.document.createElement%28%27videoMoved%27%29%3B%0A%09%09%09%09videoMovedbox.innerHTML%20%3D%20innerA%20+%20innerB%20+%20%27top%3A-15px%21important%3B%22%3E%3Cb%3E%27%20+%20videoMoved%20+%20%27%3C/b%3E%3C/div%3E%27%3B%0A%0A%09%09%09%09//loadURI%28stopPl%29%3B%0A%09%09%09%09%28function%28d%29%7Bvar%20v%3Dd.getElementById%28%27movie_player%27%29%3Bif%28v%29%7Btry%7Bv.stopVideo%28%29%7Dcatch%7B%7D%7D%0A%09%09%09%09%09else%7Bv%3Dd.getElementsByTagName%28%27video%27%29%3Bif%28v%5B0%5D%29%7Bv%5B0%5D.src%3D%27%27%3Btry%7Bv%5B0%5D.load%28%29%7Dcatch%7B%7D%7D%3B%7D%7D%29%28currentWin.document%29%3B%0A%0A%09%09%09%09currentWin.document.getElementById%28%27eow-title%27%29.appendChild%28videoMovedbox%29%3B%0A%09%09%09%09return%20true%3B%0A%09%09%09%7D%3B%0A%09%09%09for%20%28i%20%3D%200%3B%20i%20%3C%20elem.length%3B%20i++%29%20%7B%0A%09%09%09%09if%20%28%28%28tmp%20%3D%20getSrc%28elem%5Bi%5D.parentNode%2C%20currLoc%29%29%20%26%26%20tmp.length%20%3E%202%29%20%7C%7C%20%28i%20%3D%3D%200%20%26%26%20currentWin.document.body.innerHTML.substring%280%2C%207%29%20%3D%3D%20%27%3Cvideo%20%27%20%26%26%20%28tmp%20%3D%20currLoc.toString%28%29%29%29%29%20%7B%0A%0A%09%09%09%09%09if%20%28SEND%28tmp%29%29%20return%3B%0A%0A%09%09%09%09%09videoMovedbox%20%3D%20currentWin.document.createElement%28%27videoMoved%27%29%3B%0A%09%09%09%09%09videoMovedbox.innerHTML%20%3D%20innerA%20+%20innerB%20+%20%27top%3A20px%21important%3Bbackground-color%3Ablack%21important%3B%22%3E%27%20+%20videoMoved%20+%20%27%3C/div%3E%27%3B%0A%0A%09%09%09%09%09if%20%28currLoc.hostname%20%3D%3D%20%27www.youtube.com%27%29%20%7B%0A%09%09%09%09%09%09elem%5Bi%5D.parentNode.parentNode.appendChild%28videoMovedbox%29%3B%0A%09%09%09%09%09%7D%20else%20%7B%0A%09%09%09%09%09%09elem%5Bi%5D.parentNode.appendChild%28videoMovedbox%29%3B%0A%09%09%09%09%09%7D%3B%0A%09%09%09%09%09elem%5Bi%5D.src%20%3D%20%27%27%3B%0A%09%09%09%09%09try%20%7B%0A%09%09%09%09%09%09elem%5Bi%5D.load%28%29%0A%09%09%09%09%09%7D%20catch%20%28e%29%20%7B%7D%3B%0A%09%09%09%09%09return%20true%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%3B%0A%0A%09%09currentWin._elems%20%3D%20currentWin.document.getElementsByTagName%28%27iframe%27%29%3B%0A%09%09if%20%28currentWin._elems.length%20%3E%200%29%20%7B%0A%09%09%09for%20%28currentWin._iCounter%20%3D%200%3B%20currentWin._iCounter%20%3C%20currentWin._elems.length%3B%20currentWin._iCounter++%29%20%7B%0A%09%09%09%09if%20%28%28currentWin._elems%5BcurrentWin._iCounter%5D.src.indexOf%28%27youtube.com%27%29%20%3E%20-1%29%20%26%26%20%28tmp%20%3D%20currentWin._elems%5BcurrentWin._iCounter%5D.src.match%28YoutubeID%29%29%20%26%26%20%28tmp%5B1%5D.length%20%3D%3D%2011%29%29%20%7B%0A%0A%09%09%09%09if%20%28SEND%28%27https%3A//www.youtube.com/watch%3Fv%3D%27%20+%20tmp%5B1%5D%29%29%20return%3B%0A%0A%09%09%09%09currentWin._elems%5BcurrentWin._iCounter%5D.outerHTML%20%3D%20ytIMGouter%28tmp%5B1%5D%29%3B%0A%09%09%09%09%09return%20true%3B%0A%09%09%09%09%7D%3B%0A%09%09%09%09if%20%28currentWin._elems%5BcurrentWin._iCounter%5D.clientWidth%20%3E%2080%20%26%26%20currentWin._elems%5BcurrentWin._iCounter%5D.clientHeight%20%3E%2040%20%26%26%20handlWin%28currentWin._elems%5BcurrentWin._iCounter%5D.contentWindow%29%29%0A%09%09%09%09%09return%20true%3B%0A%09%09%09%7D%0A%09%09%7D%3B%0A%0A%09%09elem%20%3D%20currentWin.document.getElementsByTagName%28%27object%27%29%3B%0A%09%09currLoc%20%3D%20currentWin.location%3B%0A%09%09if%20%28elem.length%20%3D%3D%200%29%20%7B%0A%09%09%09elem%20%3D%20currentWin.document.getElementsByTagName%28%27embed%27%29%0A%09%09%7D%3B%0A%09%09if%20%28elem.length%20%3E%200%29%20%7B%0A%09%09%09for%20%28i%20%3D%200%3B%20i%20%3C%20elem.length%3B%20i++%29%20%7B%0A%09%09%09%09if%20%28elem%5Bi%5D.innerHTML.indexOf%28%27youtu%27%29%20%21%3D%20-1%20%26%26%20%28tmp%20%3D%20elem%5Bi%5D.innerHTML.match%28YoutubeID%29%29%20%26%26%20tmp%5B1%5D.length%20%3D%3D%2011%29%20%7B%0A%0A%09%09%09%09%09if%20%28SEND%28%27https%3A//www.youtube.com/watch%3Fv%3D%27%20+%20tmp%5B1%5D%29%29%20return%3B%0A%0A%09%09%09%09%09elem%5Bi%5D.outerHTML%20%3D%20ytIMGouter%28tmp%5B1%5D%29%3B%0A%09%09%09%09%09return%20true%3B%0A%09%09%09%09%7D%20else%20%7B%0A%09%09%09%09%09if%20%28elem%5Bi%5D.clientWidth%20%3E%2080%20%26%26%20elem%5Bi%5D.clientHeight%20%3E%2040%29%20%7B%0A%09%09%09%09%09%09if%20%28%28%28tmp%20%3D%20getSrc%28elem%5Bi%5D.parentNode%2C%20currLoc%29%29%20%7C%7C%20%28tmp%20%3D%20getLink%28elem%5Bi%5D%2C%20currLoc%29%29%29%20%26%26%20tmp.length%20%3E%202%29%20%7B%0A%0A%09%09%09%09%09%09%09if%20%28SEND%28tmp%29%29%20return%3B%0A%0A%09%09%09%09%09%09%09elem%5Bi%5D.outerHTML%20%3D%20innerA%20+%20%27background-color%3Ablack%21important%3Bbottom%3A20px%21important%3B%22%3E%26nbsp%3B%26nbsp%3B%27%20+%20videoMoved%20+%20%27%3C/div%3E%27%3B%0A%09%09%09%09%09%09%09return%20true%3B%0A%09%09%09%09%09%09%7D%3B%0A%09%09%09%09%09%7D%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%3B%0A%09%09%7D%3B%0A%09%09return%20false%3B%0A%09%7D%3B%0A%0A%09function%20restProtHost%28lnkR%2C%20curLoc%29%20%7B%0A%09%09if%20%28lnkR.length%20%3D%3D%200%29%0A%09%09%09return%20%27%27%3B%0A%09%09let%20tr%20%3D%20lnkR.replace%28/%5E%3A%5C/%5C//%2C%20curLoc.protocol%20+%20%22//%22%29%3B%0A%09%09if%20%28%21tr.match%28/%5Ehttps%3F%3A%5C/%5C//i%29%29%20%7B%0A%09%09%09lnkR%20%3D%20tr.replace%28/%5E%5C/+/%2C%20%27%27%29%3B%0A%09%09%09if%20%28lnkR.split%28%27/%27%29%5B0%5D.split%28%27%3F%27%29%5B0%5D.split%28%27%23%27%29%5B0%5D.toLowerCase%28%29.match%28/%5E%28%3F%3A%5B-a-z%5Cd%5D+%5C.%29+%5Ba-z%5Cd%5D%7B2%2C6%7D%24/%29%29%20%7B%0A%09%09%09%09tr%20%3D%20curLoc.protocol%20+%20%27//%27%20+%20lnkR%3B%0A%09%09%09%7D%20else%20%7B%0A%09%09%09%09tr%20%3D%20curLoc.protocol%20+%20%27//%27%20+%20curLoc.host%20+%20%22/%22%20+%20lnkR%3B%0A%09%09%09%7D%0A%09%09%7D%3B%0A%09%09return%20tr%3B%0A%09%7D%3B%0A%0A%09function%20getSrc%28vobj%2C%20currentLoc%29%20%7B%0A%09%09var%20t%20%3D%20%27%27%2C%0A%09%09tt%20%3D%20%27%27%3B%0A%09%09if%20%28%28%28%28t%20%3D%20vobj.innerHTML.match%28/%3Cvideo.*%3F%5Cssrc%3D%28%3F%3A%28%3F%3A%27%28%5B%5E%27%5D*%29%27%29%7C%28%3F%3A%22%28%5B%5E%22%5D*%29%22%29%7C%28%5B%5E%5Cs%5D*%29%29/i%29%29%20%26%26%20%28t%29%20%26%26%20%28tt%20%3D%20t%5B1%5D%20%7C%7C%20t%5B2%5D%20%7C%7C%20t%5B3%5D%29%20%26%26%20tt.indexOf%28%27blob%3A%27%29%20%3D%3D%20-1%29%20%7C%7C%20%28%28t%20%3D%20vobj.innerHTML.match%28/%3Csource.*%3F%5Cssrc%3D%28%3F%3A%28%3F%3A%27%28%5B%5E%27%5D*%29%27%29%7C%28%3F%3A%22%28%5B%5E%22%5D*%29%22%29%7C%28%5B%5E%5Cs%5D*%29%29.*%3F%5Cstype%3D%5B%27%22%5D%3Fvideo%5C//i%29%29%20%26%26%20%28t%29%20%26%26%20%28tt%20%3D%20t%5B1%5D%20%7C%7C%20t%5B2%5D%20%7C%7C%20t%5B3%5D%29%29%29%20%26%26%20tt.length%20%3E%202%20%26%26%20tt.indexOf%28%27blob%3A%27%29%20%3D%3D%20-1%29%20%7B%0A%09%09%09if%20%28tt.indexOf%28%22.mp4/%3F%22%29%20%3D%3D%20-1%29%20%7B%0A%09%09%09%09tt%20%3D%20tt.replace%28/%26amp%3B/g%2C%20%22%26%22%29%0A%09%09%09%7D%3B%0A%09%09%09t%20%3D%20restProtHost%28tt%2C%20currentLoc%29%3B%0A%09%09%09return%20t%3B%0A%09%09%7D%3B%0A%09%09return%20%27%27%3B%0A%09%7D%3B%0A%0A%09function%20getLink%28obj%2C%20curLocation%29%20%7B%0A%0A%09%09if%20%28%21obj%20%7C%7C%20%21obj.tagName%29%0A%09%09%09return%20%27%27%3B%0A%09%09q%20%3D%20obj.tagName.toLowerCase%28%29%3B%0A%0A%09%09var%20getParam%20%3D%20function%20%28e%2C%20n%29%20%7B%0A%09%09%09var%20v%20%3D%20%27%27%2C%0A%09%09%09r%20%3D%20new%20RegExp%28%27%5E%28%27%20+%20n%20+%20%27%29%24%27%2C%20%27i%27%29%2C%0A%09%09%09param%20%3D%20e.getElementsByTagName%28%27param%27%29%3B%0A%09%09%09for%20%28var%20igp%20%3D%200%2C%20p%3B%20p%20%3D%20param%5Bigp%5D%3B%20igp++%29%20%7B%0A%09%09%09%09if%20%28p.hasAttribute%28%27name%27%29%20%26%26%20p.getAttribute%28%27name%27%29.match%28r%29%29%20%7B%0A%09%09%09%09%09v%20%3D%20p.getAttribute%28%27value%27%29%3B%0A%09%09%09%09%09break%0A%09%09%09%09%7D%3B%0A%09%09%09%7D%3B%0A%09%09%09return%20v%3B%0A%09%09%7D%3B%0A%0A%09%09var%20restPath%20%3D%20function%20%28f%2C%20s%29%20%7B%0A%09%09%09return%20%28f.substring%280%2C%204%29%20%3D%3D%20%27http%27%29%20%3F%20f%20%3A%20s.replace%28/%5B%23%3F%5D.*%24/%2C%20%27%27%29.replace%28/%5B%5E%5C/%5D*%24/%2C%20f%29%0A%09%09%7D%3B%0A%0A%09%09function%20videoLinkExtract%28fl%29%20%7B%0A%09%09%09alert%28fl%29%3B%0A%09%09%09var%20linkArr%20%3D%20%5B%5D%2C%0A%09%09%09outLinks%20%3D%20%5B%5D%2C%0A%09%09%09jj%20%3D%200%2C%0A%09%09%09lba%20%3D%20%27%27%2C%0A%09%09%09lbb%20%3D%20%27%27%2C%0A%09%09%09decodeURL%20%3D%20gBrowser.currentURI.spec%3B%20%7B%0A%09%09%09%09try%20%7B%0A%09%09%09%09%09return%20decodeURIComponent%28s%29%0A%09%09%09%09%7D%20catch%20%28e%29%20%7B%0A%09%09%09%09%09return%20unescape%28s%29%0A%09%09%09%09%7D%0A%09%09%09%7D%3B%0A%0A%09%09%09for%20%28var%20ij%20%3D%200%3B%20ij%20%3C%203%3B%20ij++%29%20%7B%0A%09%09%09%09lba%20%3D%20lba%20+%20String.fromCharCode%28parseInt%28%28Math.random%28%29%20*%2015%20+%201%29%20+%20%27%27%2C%2010%29%29%3B%0A%09%09%09%09lbb%20%3D%20lbb%20+%20String.fromCharCode%28parseInt%28%28Math.random%28%29%20*%2015%20+%2016%29%20+%20%27%27%2C%2010%29%29%3B%0A%09%09%09%7D%3B%0A%0A%09%09%09function%20pushWithMerit%28lnk%29%20%7B%0A%0A%09%09%09%09var%20merit%20%3D%20-11%3B%0A%09%09%09%09if%20%28lnk.match%28/%5Ehttps%3F%3A%5C/%5C//i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%2040%3B%0A%09%09%09%09if%20%28outLinks.length%20%3D%3D%200%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%201%3B%0A%09%09%09%09if%20%28lnk.match%28/%5E%5C//%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%207%3B%0A%09%09%09%09if%20%28lnk.match%28/%5E%5C/%5C//%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%2030%3B%0A%09%09%09%09if%20%28lnk.match%28/240p%28%5B%5Ea-z%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%201%3B%0A%09%09%09%09if%20%28lnk.match%28/%5B%5Ea-z%5D240%28%5B%5Ea-z0-9%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%201%3B%0A%09%09%09%09if%20%28lnk.match%28/360p%28%5B%5Ea-z%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%203%3B%0A%09%09%09%09if%20%28lnk.match%28/%5B%5Ea-z%5D360%28%5B%5Ea-z0-9%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%203%3B%0A%09%09%09%09if%20%28lnk.match%28/480p%28%5B%5Ea-z%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%205%3B%0A%09%09%09%09if%20%28lnk.match%28/%5B%5Ea-z%5D480%28%5B%5Ea-z0-9%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%205%3B%0A%09%09%09%09if%20%28lnk.match%28/720p%28%5B%5Ea-z%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%207%3B%0A%09%09%09%09if%20%28lnk.match%28/%5B%5Ea-z%5D720%28%5B%5Ea-z0-9%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%207%3B%0A%09%09%09%09if%20%28lnk.match%28/%5C.mp4%28%5B%5Ea-z%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%208%3B%0A%09%09%09%09if%20%28lnk.match%28/_hd%28%5B%5Ea-z%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20+%206%3B%0A%09%09%09%09if%20%28lnk.match%28/%5C.%28jpg%7Cxml%29%28%5B%5Ea-z%5D%7C%24%29/i%29%29%0A%09%09%09%09%09merit%20%3D%20merit%20-%2040%3B%0A%09%09%09%09if%20%28merit%20%3E%200%29%0A%09%09%09%09%09outLinks.push%28merit%20+%20lba%20+%20lnk%29%3B%0A%09%09%09%09Services.console.logStringMessage%28%27merit%3A%27%20+%20merit%20+%20%27%20lnk-%3E%27%20+%20lnk%29%3B%0A%09%09%09%7D%3B%0A%0A%09%09%09linkArr.push%28fl%29%3B%0A%09%09%09while%20%28linkArr.length%20%3E%20jj%20%26%26%20jj%20%3C%2030%29%20%7B%0A%0A%09%09%09%09var%20testPaths%20%3D%20%5B%5D%3B%0A%09%09%09%09testPaths%20%3D%20linkArr%5Bjj%5D.split%28/%28%5C.%28%3F%3Aflv%7Cmp4%7Cm3u8%29%29/i%29%3B%0A%09%09%09%09if%20%28testPaths%5BtestPaths.length%20-%201%5D%20%3D%3D%20%27%27%29%0A%09%09%09%09%09testPaths.pop%28%29%3B%0A%0A%09%09%09%09for%20%28k%20%3D%201%3B%20k%20%3C%20testPaths.length%3B%20k%20%3D%20k%20+%202%29%20%7B%0A%0A%09%09%09%09%09if%20%28testPaths%5Bk%20-%201%5D.indexOf%28lba%29%20%3E%20-1%29%20%7B%0A%09%09%09%09%09%09pref%20%3D%20testPaths%5Bk%20-%201%5D%3B%0A%09%09%09%09%09%7D%20else%20%7B%0A%09%09%09%09%09%09var%20testAboutDom%20%3D%20testPaths%5Bk%20-%201%5D.toLowerCase%28%29.split%28/%28https%3F%3A%5C/%5C/%29/%29%3B%0A%09%09%09%09%09%09if%20%28testAboutDom%5BtestAboutDom.length%20-%201%5D%20%3D%3D%20%27%27%29%0A%09%09%09%09%09%09%09testAboutDom.pop%28%29%3B%0A%09%09%09%09%09%09var%20pTest%20%3D%20testAboutDom%5BtestAboutDom.length%20-%201%5D.split%28/%28%5C%3F%5B%5E%5C%3F%5D*%3F%26%29/%29%3B%0A%09%09%09%09%09%09if%20%28pTest.length%20%3E%202%29%20%7B%0A%09%09%09%09%09%09%09pTest.pop%28%29%3B%0A%09%09%09%09%09%09%09pTest.pop%28%29%3B%0A%09%09%09%09%09%09%7D%3B%0A%09%09%09%09%09%09testAboutDom%5BtestAboutDom.length%20-%201%5D%20%3D%20pTest.join%28%27%27%29%3B%0A%09%09%09%09%09%09pref%20%3D%20testPaths%5Bk%20-%201%5D.substring%28testAboutDom.join%28%27%27%29.lastIndexOf%28%22%26%22%29%20+%201%29%3B%0A%09%09%09%09%09%7D%3B%0A%0A%09%09%09%09%09t2%20%3D%20pref.lastIndexOf%28lbb%29%3B%0A%09%09%09%09%09if%20%28t2%20%3E%20-1%29%20%7B%0A%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%203%29%3B%0A%09%09%09%09%09%7D%20else%20%7B%0A%0A%09%09%09%09%09%09t2%20%3D%20pref.lastIndexOf%28%27%7B%22%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%202%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.lastIndexOf%28%27%5B%22%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%202%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.lastIndexOf%28%27%2C%22%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%202%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.toLowerCase%28%29.lastIndexOf%28%27%22http%3A//%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%201%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.toLowerCase%28%29.lastIndexOf%28%27%22https%3A//%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%201%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.toLowerCase%28%29.lastIndexOf%28%27%2Chttp%3A//%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%201%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.toLowerCase%28%29.lastIndexOf%28%27%2Chttps%3A//%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%201%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.toLowerCase%28%29.lastIndexOf%28%27%3Bhttp%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%201%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.toLowerCase%28%29.lastIndexOf%28%27*https%3A//%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%201%29%3B%0A%09%09%09%09%09%09t2%20%3D%20pref.toLowerCase%28%29.lastIndexOf%28%27%20or%20%27%29%3B%0A%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%204%29%3B%0A%0A%09%09%09%09%09%09pref%20%3D%20pref.substring%28pref.split%28%27/%27%29%5B0%5D.toLowerCase%28%29.split%28%27%252f%27%29%5B0%5D.lastIndexOf%28%27%3D%27%29%20+%201%29%3B%0A%0A%09%09%09%09%09%7D%0A%0A%09%09%09%09%09if%20%28pref.length%20%3E%200%29%20%7B%0A%0A%09%09%09%09%09%09if%20%28pref.split%28%27%3F%27%29%5B0%5D.toLowerCase%28%29.match%28/%25%5B2-3%5D%5B0-9a-f%5D/%29%29%20%7B%0A%0A%09%09%09%09%09%09%09t2%20%3D%20pref.indexOf%28%27%22%27%29%0A%09%09%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%201%29%3B%0A%09%09%09%09%09%09%09%09suff%20%3D%20testPaths%5Bk%20+%201%5D%20%3F%20testPaths%5Bk%20+%201%5D.split%28%27%26%27%29%5B0%5D.split%28%27%22%27%29%5B0%5D.split%28%27%3B%27%29%5B0%5D.split%28/%2Chttp/i%29%5B0%5D%20%3A%20%27%27%3B%0A%09%09%09%09%09%09%09if%20%28%28suff%20%21%3D%20testPaths%5Bk%20+%201%5D%29%20%7C%7C%20%28testPaths.length%20%3C%20k%20+%203%29%29%20%7B%0A%09%09%09%09%09%09%09%09if%20%28testPaths.length%20%3E%20k%20+%201%29%20%7B%0A%09%09%09%09%09%09%09%09%09testPaths%5Bk%20+%201%5D%20%3D%20%28%28pref%20%3D%3D%20testPaths%5Bk%20-%201%5D%29%20%3F%20%27%27%20%3A%20%27%26%27%29%20+%20testPaths%5Bk%20+%201%5D.substr%28suff.length%29%0A%09%09%09%09%09%09%09%09%7D%3B%0A%09%09%09%09%09%09%09%09t2%20%3D%20pref.lastIndexOf%28lba%29%3B%0A%09%09%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%203%29%0A%09%09%09%09%09%09%09%09%09%09linkArr.push%28decodeURL%28pref%20+%20testPaths%5Bk%5D%20+%20suff%29%29%3B%0A%0A%09%09%09%09%09%09%09%7D%20else%20%7B%0A%09%09%09%09%09%09%09%09testPaths%5Bk%20+%201%5D%20%3D%20%28pref%20%3D%3D%20testPaths%5Bk%20-%201%5D%20%3F%20%27%27%20%3A%20lbb%29%20+%20pref%20+%20testPaths%5Bk%5D%20+%20suff%0A%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%7D%20else%20%7B%0A%09%09%09%09%09%09%09suff%20%3D%20testPaths%5Bk%20+%201%5D%20%3F%20testPaths%5Bk%20+%201%5D.split%28%27%3B%27%29%5B0%5D.split%28%27%22%5D%27%29%5B0%5D.split%28%27%22%7D%27%29%5B0%5D.split%28%27%22%2C%27%29%5B0%5D.split%28/%2Chttps%3F%3A%5C/%5C//i%29%5B0%5D.split%28%27*https%3A//%27%29%5B0%5D.split%28%27%20or%20%27%29%5B0%5D%20%3A%20%27%27%3B%0A%09%09%09%09%09%09%09t2%20%3D%20suff.indexOf%28%27%26%27%29%3B%0A%09%09%09%09%09%09%09if%20%28%28t2%20%3E%20-1%29%20%26%26%20%28pref%20%21%3D%20testPaths%5Bk%20-%201%5D%29%29%20%7B%0A%09%09%09%09%09%09%09%09if%20%28t2%20%3D%3D%200%29%0A%09%09%09%09%09%09%09%09%09suff%20%3D%20%27%27%3B%0A%09%09%09%09%09%09%09%09if%20%28suff.charAt%280%29%20%21%3D%20%27%3F%27%29%0A%09%09%09%09%09%09%09%09%09suff%20%3D%20suff.split%28/%28%26%5B%5E%26%5D+%3Dhttps%3F%3A%5C/%5C/%29/i%29%5B0%5D%3B%0A%09%09%09%09%09%09%09%7D%3B%0A%09%09%09%09%09%09%09if%20%28%28suff%20%21%3D%20testPaths%5Bk%20+%201%5D%29%20%7C%7C%20%28testPaths.length%20%3C%20k%20+%203%29%29%20%7B%0A%09%09%09%09%09%09%09%09if%20%28testPaths.length%20%3E%20k%20+%201%29%20%7B%0A%09%09%09%09%09%09%09%09%09testPaths%5Bk%20+%201%5D%20%3D%20%28%28pref%20%3D%3D%20testPaths%5Bk%20-%201%5D%29%20%3F%20%27%27%20%3A%20%27%26%27%29%20+%20testPaths%5Bk%20+%201%5D.substr%28suff.length%29%0A%09%09%09%09%09%09%09%09%7D%3B%0A%09%09%09%09%09%09%09%09t2%20%3D%20pref.lastIndexOf%28lba%29%3B%0A%09%09%09%09%09%09%09%09if%20%28t2%20%3E%20-1%29%0A%09%09%09%09%09%09%09%09%09pref%20%3D%20pref.substring%28t2%20+%203%29%3B%0A%09%09%09%09%09%09%09%09pushWithMerit%28pref%20+%20testPaths%5Bk%5D%20+%20suff%29%3B%0A%0A%09%09%09%09%09%09%09%7D%20else%20%7B%0A%09%09%09%09%09%09%09%09testPaths%5Bk%20+%201%5D%20%3D%20lba%20+%20%28pref%20%3D%3D%20testPaths%5Bk%20-%201%5D%20%3F%20%27%27%20%3A%20lbb%29%20+%20pref%20+%20testPaths%5Bk%5D%20+%20suff%0A%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%3B%0A%09%09%09%09jj%20%3D%20jj%20+%201%3B%0A%09%09%09%7D%3B%0A%0A%09%09%09if%20%28outLinks.length%20%3D%3D%200%29%0A%09%09%09%09return%20%27%27%3B%0A%09%09%09function%20srt%28a%2C%20b%29%20%7B%0A%09%09%09%09a%20%3D%20parseInt%28a.substr%280%2C%20a.indexOf%28lba%29%29%2C%2010%29%3B%0A%09%09%09%09b%20%3D%20parseInt%28b.substr%280%2C%20b.indexOf%28lba%29%29%2C%2010%29%3B%0A%09%09%09%09if%20%28a%20%3C%20b%29%0A%09%09%09%09%09return%201%3B%0A%09%09%09%09if%20%28a%20%3E%20b%29%0A%09%09%09%09%09return%20-1%3B%0A%09%09%09%09return%200%0A%09%09%09%7D%3B%0A%09%09%09outLinks.sort%28srt%29%3B%0A%09%09%09outLinks%5B0%5D%20%3D%20outLinks%5B0%5D.substr%28outLinks%5B0%5D.indexOf%28lba%29%20+%203%29%0A%09%09%09%09if%20%28outLinks%5B0%5D.indexOf%28%27_hq.mp4/%3Ftime%3D%27%29%20%3E%200%29%0A%09%09%09%09%09outLinks%5B0%5D%20%3D%20outLinks%5B0%5D.replace%28/%26/g%2C%20%27%26amp%3B%27%29%3B%0A%09%09%09%09return%20outLinks%5B0%5D%3B%0A%09%09%7D%3B%0A%0A%09%09if%20%28%21ol%29%0A%09%09%09return%20%27%27%3B%0A%09%09//ol%20%3D%20ol.replace%28/%5E%3A%3F%5C/%5C//%2C%20curLocation.protocol%20+%20%22//%22%29%3B%0A%09%09//return%20restPath%28ol%2C%20src%29%3B%0A%09%09return%20restProtHost%28ol%2C%20curLocation%29%3B%0A%09%7D%3B%0A%0A%09try%20%7BhandlWin%28content%29%3B%7D%20finally%20%7Bfound%20%7C%7C%20SEND%28%29%3B%7D%0A%7D%29%3B%0A%0A%20var%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%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

Отредактировано ВВП (06-01-2023 15:05:25)

Отсутствует

 

№1664706-01-2023 17:09:48

xrun1
Участник
 
Группа: Members
Зарегистрирован: 12-12-2013
Сообщений: 1228
UA: Firefox 108.0

Re: Custom Buttons

Oakwood
1. Кнопка Autocopy больше не работает. Я сделал себе скрипт для Tampermonkey. Смотрите здесь.
Может кто-нибудь подскажет другое решение.
2. Auto Activate Tabs. Рабочий код с пикселями сверху не подскажу. Просто код, активирующий вкладку наведением мышки можно скомпоновать из старого кода и правки к нему.

Получается такой код

Выделить код

Код:

//Активизировать вкладку наведением курсора......................
var tab_hover={
   event:null,
   tid:null,

   onLoad: function() {
      gBrowser.tabContainer.addEventListener("mouseout", tab_hover.onMouseOut, false);
      gBrowser.tabContainer.addEventListener("mouseover", tab_hover.onMouseOver, false);
   },
   onUnload: function() {
      gBrowser.tabContainer.removeEventListener("mouseover", tab_hover.onMouseOver, false);
      gBrowser.tabContainer.removeEventListener("mouseout", tab_hover.onMouseOut, false);
   },

   onMouseOver: e => tab_hover.tid = setTimeout(tab_hover.activate, 200, e.target),
   activate: trg => gBrowser.selectedTab = trg.closest("tab"),

   onMouseOut: function() {
      clearTimeout(tab_hover.tid);
   }
};
if (!this.tab_hoverRun) tab_hover.onLoad();
this.tab_hoverRun = true;


Код старенький, работает и, наверное, его можно оптимизировать, но моих знаний на это не хватает.

Отсутствует

 

№1664808-01-2023 17:01:32

Oakwood
Участник
 
Группа: Members
Зарегистрирован: 01-01-2023
Сообщений: 15
UA: Firefox 108.0

Re: Custom Buttons

ВВП пишет

Не актуально...Yt downloader

А что за программа? Аналог yt-dlp.exe? Можно ссылку на оф. сайт?

xrun1
Спасибо большое, хоть выход, кнопку Autocopy может быть сможет реанимировать Dumby, когда вернётся, всё-таки основная кнопка CB. Auto Activate Tabs это то, ради чего только CB можно поставить, очень удобно, спасибо. :)

Отсутствует

 

№1664908-01-2023 18:27:19

ВВП
Участник
 
Группа: Members
Зарегистрирован: 13-03-2021
Сообщений: 337
UA: Firefox 107.0

Отсутствует

 

№1665010-01-2023 00:16:08

Dumby
Участник
 
Группа: Members
Зарегистрирован: 12-08-2012
Сообщений: 2259
UA: Firefox 78.0

Re: Custom Buttons

Oakwood пишет

кнопку Autocopy может быть сможет реанимировать Dumby

Сомнительно. Сложновато это для меня. Но попробовать могу.

скрытый текст

Выделить код

Код:

this.closest("toolbarpaletteitem") || ((id, func) => {
	var PREF_ENABLED = 1, PREF_BLINK = 2, PREF_RESET = 4;
	var g = Cu.getGlobalForObject(Cu), autocopy = g[id];
	if (!autocopy) {
		var cid = id + " Child";
		var pref = "CB.Autocopy.settings", topic = "quit-application-granted";
		(autocopy = g[id] = {
			init() {
				this.readSettings();
				Services.obs.addObserver(this, topic);
				this[PREF_ENABLED] && this.initChild();
			},
			destroy(reason) {
				if (reason && reason[5] != "e") {
					var e = Cu.getGlobalForObject(reason.constructor).event;
					if (!e || e.target.id != "custombuttons-contextpopup-move-removeFromToolbar") return;
				}
				delete g[id];
				this.saveSettings();
				reason == "delete" && Services.prefs.clearUserPref(pref);
				Services.obs.removeObserver(this, topic);
				this[PREF_ENABLED] && this.destroyChild();
			},
			get processURL() {
				var prfx = `data:,globalThis["${cid}"]?.`;
				this.scriptBlink = prfx + "setBlink()";
				this.scriptDestroy = prfx + "destroy()";

				delete this.processURL;
				return this.processURL = `data:,(${encodeURIComponent(func)}\n)("${cid}");`;
			},
			initChild() {
				Object.defineProperty(g, cid, this.desc);
				Services.ppmm.loadProcessScript(this.processURL, true);
			},
			desc: {configurable: true, set(val) {
				val.topics.pop();
				val.observe = autocopy.handleDoc;
				val.enumerator = autocopy.enumerator;
				delete g[cid];
				g[cid] = val;
			}},
			* enumerator() {
				for(var win of Services.wm.getEnumerator("navigator:browser"))
					for(var br of win.gBrowser.browsers)
						if (!br.isRemoteBrowser) yield br;
			},
			handleDoc(doc) {
				if (doc.ownerGlobal?.browsingContext.top.embedderElement
					?.matches("#tabbrowser-tabpanels .browserStack > :scope"))
						this.initDoc(doc);
			},
			destroyChild() {
				Services.ppmm.removeDelayedProcessScript(this.processURL);
				Services.ppmm.loadProcessScript(this.scriptDestroy, false);
			},
			readSettings() {
				this.prefVal = Services.prefs.getIntPref(pref, 3);
				for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
					this[setting] = Boolean(this.prefVal & setting);
			},
			saveSettings() {
				var settings = 0;
				for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
					if (this[setting]) settings += setting;
				if (this.prefVal != settings)
					Services.prefs.setIntPref(pref, settings);
			},
			observe() {
				if (this[PREF_RESET]) this[PREF_ENABLED] &&= false;
				this.destroy();
			},
			newState(trg) {
				var pref = trg.value, val = this[pref] = !this[pref];
				if (pref == PREF_ENABLED) {
					val ? this.initChild() : this.destroyChild();
					for(var win of Services.wm.getEnumerator("navigator:browser")) {
						var btn = win.document.getElementById(_id);
						btn && this.setImg(btn, val);
					}
				} else if (pref == PREF_BLINK)
					this.saveSettings(),
					Services.ppmm.loadProcessScript(this.scriptBlink, false);
			},
			icons: {
				true: "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgMBAAQIAAcEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAcACAMEAQEAAAAAAAAAAAAAAAACAwADAAAAABUnAB9cqgC3a7wB4Gq5Ad1qugHearoB3mq6Ad5qugHearoB3mi4AN1qugHgYrMAxR43AC8AAAAAAAEAAAECAAQAAAQAV6AAprP9Vv/W/qn80/+f/9T/ov/U/6L/1P+i/9T/ov/U/6L/1/+n/9X+pfy3/WL/Y7QAvwEAAQAAAAAAFSgAH1ehAKlyzwD1htgf/YzcJ/2K2yP9i9sk/YvbJf2L2yX9i9sm/YnaIv2b4kP92/21/Nf+qv9quwHdBQkACAAAAQBeqwCzr/tR/8X0j/u+8X//vvJ//77ygP++8oD/vvKA/77yf/+98n7/wvSH/4zcKv+e4kv93v+0/2i5AN0DBwAIBQkACGu8AdzV/af/4v/B/d//u//h/7//4f+//+H/v//h/7//4f+//9/+u//n/8n/w/GK/4zaK/3g/7r/aroC3gMHAAgEBwAIarkC3dX/pf/g/sD93v67/9/+vv/g/r//4P6//+D+v//f/r7/3f66/+T/xv/B8Yb/j9st/eT/w/9qugPeAwcACAQHAAhqugLe2v+w/+j/z/3l/8r/5//N/+f/zv/n/87/5//O/+f/zf/l/sj/7P/W/8Xyj/+Q2y/96f/N/2q6A94DBwAIBAcACGq6At7f/7n/7v/c/ev/1v/t/9n/7f/a/+3/2v/t/9r/7f/Z/+r+1f/y/+P/yPKW/5DbMf3s/9X/aroE3gMHAAgEBwAIaroC3uP/wf/z/+j98P/h//L/5P/z/+X/8//l//P/5f/y/+T/8P7g//j/7v/L8p3/kdsy/fD/3P9rugTeAwcACAQHAAhqugLe5v/J//j/8v31/+r/9v/t//f/7v/3/+//9//u//b/7f/0/un//f/4/87yo/+R2zL98f/f/2q5Bd0DBwAIBAcACGq6At7p/8///P/6/fj/8f/6//T/+v/1//r/9f/6//X/+v/0//f+8P//////0fGo/5PbNf30/+f/a7wE3AQJAAgEBwAIabkC3er/0f/+//79+v/0//v/9//8//j//P/4//z/+P/7//f/+f70///////T8qz/i9go+8P9ef9dqwCzAAACAAUJAAhquwHd7f7a//////z+//39/////f////3////9/////f////39/vz9/////dzzvv5v0AD1VqECqRUnAB8AAAAAAQACAGK0AL/J/Yf/8v7k/O3/1//u/9n/7v/Z/+7/2f/u/9n/7v/Z/+3/1//x/eP8vfxu/1WgAKYAAAUAAQIABAABAAAAAAAAHjcALmGzAMVquwLgarkC3Wq6At5qugLearoC3mq6At5qugLearkC3Wu8AeBbqgC3FScAHwAAAAACAwADAAAAAAAAAAAAAAAAAwQCAQQIAAgEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAgABwMDAgAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
				false: "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgEDAAQACAcEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAHCAMBBAEAAAAAAAAAAAAAAAACAAMDAAAAABUAJx9cAKq3awG84GoBud1qAbreagG63moBut5qAbreagG63mgAuN1qAbrgYgCzxR4ANy8AAAAAAAABAAEAAgQABAAAVwCgprNW/f/Wqf7805///9Si///Uov//1KL//9Si///Uov//16f//9Wl/vy3Yv3/YwC0vwEBAAAAAAAAFQAoH1cAoalyAM/1hh/Y/Ywn3P2KI9v9iyTb/Ysl2/2LJdv9iybb/Yki2v2bQ+L927X9/Neq/v9qAbvdBQAJCAABAABeAKuzr1H7/8WP9Pu+f/H/vn/y/76A8v++gPL/voDy/75/8v+9fvL/wof0/4wq3P+eS+L93rT//2gAud0DAAcIBQAJCGsBvNzVp/3/4sH//d+7///hv///4b///+G////hv///4b///9+7/v/nyf//w4rx/4wr2v3guv//agK63gMABwgEAAcIagK53dWl///gwP793rv+/9++/v/gv/7/4L/+/+C//v/fvv7/3br+/+TG///BhvH/jy3b/eTD//9qA7reAwAHCAQABwhqArre2rD//+jP//3lyv//583//+fO///nzv//587//+fN///lyP7/7Nb//8WP8v+QL9v96c3//2oDut4DAAcIBAAHCGoCut7fuf//7tz//evW///t2f//7dr//+3a///t2v//7dn//+rV/v/y4///yJby/5Ax2/3s1f//agS63gMABwgEAAcIagK63uPB///z6P/98OH///Lk///z5f//8+X///Pl///y5P//8OD+//ju///LnfL/kTLb/fDc//9rBLreAwAHCAQABwhqArre5sn///jy//316v//9u3///fu///37///9+7///bt///06f7//fj//86j8v+RMtv98d///2oFud0DAAcIBAAHCGoCut7pz////Pr//fjx///69P//+vX///r1///69f//+vT///fw/v//////0ajx/5M12/305///awS83AQACQgEAAcIaQK53erR///+/v/9+vT///v3///8+P///Pj///z4///79///+fT+///////TrPL/iyjY+8N5/f9dAKuzAAIAAAUACQhqAbvd7dr+//////z+/f/9/////f////3////9/////f////39/P79/////dy+8/5vAND1VgKhqRUAJx8AAAAAAQIAAGIAtL/Jh/3/8uT+/O3X///u2f//7tn//+7Z///u2f//7tn//+3X///x4/38vW78/1UAoKYABQAAAQACBAAAAQAAAAAAHgA3LmEAs8VqArvgagK53WoCut5qArreagK63moCut5qArreagK53WsBvOBbAKq3FQAnHwAAAAACAAMDAAAAAAAAAAAAAAAAAwIEAQQACAgEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAIBwMCAwAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
			},
			setImg(btn, val = this[PREF_ENABLED]) {
				btn.icon.src = this.icons[val];
			},
			updatePopup(popup) {
				for(var menuitem of popup.children) this[menuitem.value]
					? menuitem.setAttribute("checked", true)
					: menuitem.removeAttribute("checked");
			},
		
		}).init();
	}
	addDestructor(r => g[id]?.destroy(r));

	autocopy.setImg(this);
	this.value = PREF_ENABLED;
	this._handleClick = () => autocopy.newState(this);
	this.oncontextmenu = e => {
		if (e.ctrlKey || e.shiftKey) return;

		var df = MozXULElement.parseXULToFragment(`
			<menupopup context="" onclick="event.stopPropagation()"
				oncommand="autocopy.newState(event.target)"
				onpopupshowing="autocopy.updatePopup(this)">
	
				<menuitem type="checkbox" value="${PREF_BLINK}"
					label="Выделенный текст мигает при автокопировании"/>
				<menuitem type="checkbox" value="${PREF_RESET}"
					label="Выключать автокопирование при выходе из браузера"/>
			</menupopup>
		`);
		df.firstChild.autocopy = autocopy;
		this.prepend(df);
		(this.oncontextmenu = e => this.setAttribute(
			"context", e.ctrlKey || e.shiftKey ? "custombuttons-contextpopup" : "_child"
		))(e);
	}
})("CB AutoCopy Button", id => (globalThis[id] = {
	re: /\S/,
	sym: Symbol(),
	topics: ["document-element-inserted", "content-child-shutdown"],
	reasons: ["MOUSEUP", "KEYPRESS", "SELECTALL"]
		.map(reason => Ci.nsISelectionListener[reason + "_REASON"]),
	init() {
		for(var win of this.windows()) this.initDoc(win.document);
		for(var topic of this.topics) Services.obs.addObserver(this, topic);
		this.setBlink();
	},
	destroy() {
		for(var topic of this.topics) Services.obs.removeObserver(this, topic);
		for(var {document} of this.windows()) document[this.sym] && this.destroyDoc(document);
		delete globalThis[id];
	},
	observe(subj, topic) {
		topic.startsWith("d") ? this.initDoc(subj) : this.destroy();
	},
	initDoc(doc) {
		if (doc[this.sym]) return;
		var sel = doc.getSelection();
		if (!sel) return;

		sel.addSelectionListener(this);
		doc[this.sym] = true;
		doc.ownerGlobal.addEventListener("unload", this, {once: true});
	},
	destroyDoc(doc) {
		doc.getSelection()?.removeSelectionListener(this);
		delete doc[this.sym];
	},
	handleEvent(e) {
		this.destroyDoc(e.target);
	},
	notifySelectionChanged(doc, sel, reason) {
		if (this.reasons.includes(reason) && this.re.test(sel)) {
			var win = doc.ownerGlobal, ds = win.docShell;
			ds.doCommand("cmd_copy");
			if (this.noBlink) return;

			var sc = ds.QueryInterface(Ci.nsIInterfaceRequestor)
				.getInterface(Ci.nsISelectionDisplay)
				.QueryInterface(Ci.nsISelectionController);

			win.setTimeout(this.repaint, 50, sc, sc.SELECTION_OFF);
			win.setTimeout(this.repaint, 200, sc, sc.SELECTION_ON);
		}
	},
	repaint(sc, disp) {
		sc.setDisplaySelection(disp);
		sc.repaintSelection(sc.SELECTION_NORMAL);
	},
	enumerator: Services.ww.getWindowEnumerator,
	* windows() {
		for(var obj of this.enumerator()) {
			var top = obj.browsingContext;
			if (top) for(var bc of top.getAllBrowsingContextsInSubtree())
				if (bc.currentWindowContext?.isInProcess) yield bc.associatedWindow;
		}
	},
	QueryInterface: ChromeUtils.generateQI(["nsISelectionListener"]),
	setBlink() {
		this.noBlink = !(Services.prefs.getIntPref("CB.Autocopy.settings", 3) & 2);
	}
}).init());

Отсутствует

 

Board footer

Powered by PunBB
Modified by Mozilla Russia
Copyright © 2004–2020 Mozilla Russia GitHub mark
Язык отображения форума: [Русский] [English]