в вновь создаваемых кнопках в секциях Код и Инициализация отсутствуют /*CODE*/ и /*Initialization Code*/ так должно быть или только у меня?
Нет, такой косяк определённо есть.
Я постараюсь исправить (или нужно срочно?).
А «В кнопке», что-то я не смог увидеть
никакого отвала с хромской стороны.
Отсутствует
Dumby нет срочно не нужно, а кнопка работает нормально, это я ступил немного. Я то пытался ей поработать на about:addons, думал что если aboutaddons.html, то будет работать, а там действительно 2 и 3 пункт не работает.
Отсутствует
Можно этот код приспособить под CB, ну или еще как-то..
function header{if(header.name===undefined){return false;} //change the disposition to 'inline' so no popup will be shown. if(header.name.toLowerCase()==='content-disposition'&&header.value.includes('attachment')){ header.value=header.value.replace('attachment;','inline;');return true;} return false;}; function request{return new Promise((resolve)=>{ //console.log(request.responseHeaders); if(request.responseHeaders.find(findContentDisposition)){ //log to the browser console console.log("Modified content-disposition header from 'attachment' to 'inline'.");} resolve({responseHeaders:request.responseHeaders});});}; browser.webRequest.onHeadersReceived.addListener(overrideJsonHeader,{urls:['<all_urls>']},['blocking','responseHeaders']);
Отредактировано func4ptch4 (18-12-2019 15:49:55)
Отсутствует
Это продолжать в ini пихать?
Верно, я так и написал.
Но, кстати да, у меня ведь тоже есть лисицы на libportable.
Пожалуй добавлю им в config.js код, который будет на выходе
записывать в ini значение, соответственно настройке.
// try {(os => os.addObserver(function obs(s, topic) { os.removeObserver(obs, topic); var ini = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIDirectoryService) .QueryInterface(Ci.nsIProperties).get("GreD", Ci.nsIFile); ini.append("portable.ini"); var parser = Cc["@mozilla.org/xpcom/ini-parser-factory;1"] .getService(Ci.nsIINIParserFactory).createINIParser(ini); var section = "Env", key = "MOZ_FORCE_DISABLE_E10S"; var pref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch) .getBoolPref("browser.tabs.remote.autostart", true) ? "" : "1"; var state; try { state = parser.getString(section, key); } catch(ex) {} if (state === pref) return; Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment).set(key, pref); parser.QueryInterface(Ci.nsIINIParserWriter).setString(section, key, pref); parser.writeFile(ini); }, "quit-application-granted", false))( Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService) )} catch(ex) {Cu.reportError(ex);}
Можно этот код приспособить под CB
Код кнопок исполняется в окне браузера.
Объекта browser с гуглячими свойствами типа webRequest'а в нём нет.
Не знаю, может есть какой хитрый способ его обрести, не задумывался.
Если есть в наличии невыключенный WebExtensions у которого в манифесте
прописаны нужные permissions, то можно ему в background отправить скрипт.
Я вот положил во вкладку Код, нажал, и всё, http-страницы открываются как текст.
Так что, можно. Но совершенно непонятно зачем. Проще ведь не будет,
представляет разве что чисто академический интерес.
var subScriptURL = "data:," + encodeURIComponent(` browser.webRequest.onHeadersReceived.addListener(details => { for(var header of details.responseHeaders) { if (header.name.toLowerCase() == "content-type") { header.value = "text/plain"; break; } } return details; }, {urls: ["<all_urls>"]}, ["blocking", "responseHeaders"]); `); var url = "data:," + encodeURIComponent( `Cc["@mozilla.org/moz/jssubscript-loader;1"] .getService(Ci.mozIJSSubScriptLoader) .loadSubScript("${subScriptURL}", content);` ); var id = "webcompat@mozilla.org"; WebExtensionPolicy.getByID(id).extension._backgroundPageFrameLoader .messageManager.loadFrameScript(url, false);
Отсутствует
Dumby
Ну, ты велика глава ! Код работает...Тогда и кнопка надо ...Да, рестарт нужен непростой, короче, после рестарта все срабатывает...это Гуд! Код UrL
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/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACuklEQVR42n1TXUhTYRh+v2/nZ06PTm1tilm4amqpFGmUVCJdVEaJikJ104V1kQhSXUQFQUJ0aYIlRF0I+YMtAol+KRDqpogomG3NkNnJ9JTTqdvO39d3jjk1Vi8HDrzf+zzv8/4h+Idl85zTxVpzEACakGM/JFkWk8Whvx1VWY6aM/mFbeVWodyuaulI1yCM0Nz72OyHLjHY+XRa6k9KwCLgr2wu7Wx1uZut0iREdBkIXuYXFAJqegZ0SeP9l0L+0zFNn1lFcN1T1nNu7foT4alvoGFi+rJu3zL/M80toBIVGA3AbhPg5i/xSctY4DB9Uk2CHRn26mellS8UA7yiKKd3Ue1EXVPCxxIMPMdBTfDT8eH5uXtm+I2isgcnbWm1kflIIlBfIlJpWsaS8GNFB8GWCr2S+PqUGNqDeIyFV9t3BgvkuEMmVDrGgCwWEOrrQGhqNEGhg4fAwnDLKlgOxmML8X0Bnwc5Oc79snSbT5DjrGY2hQDRCSBVhXVDQwmCRNdTUsCCEMypClT7fZXIwXPu58VbfXaimQRA/pQQjULBo8erCPQUqgJhMAoyCPb7P+9GDEJpQyVbAkUs65INNP2QrgOhmdw9vSZwtP7oYnZaGlB1rAXD1+hC9MCIv8hs1YUNeX0tOa6miKZRMFmUwbKwqWfABAYajgBimEQZaZTorigOXwx9rzIJ8ni2wlvieWPneKzS7ECbmX+5HWyFxSbgp3cApME+KgEBQ7sU1VWo+zhS/yUmexNTP+bM7LjqKWhVCAJFjgNDlkdnmLFcrIUBniKujY7d7xalxpXTNoypdWS0n92Yfz7XasUKnbdKJ7FkNisHk/E4dARDd3onp9uoazbpMeXyzN6GnDWtFVnpuzI1NRthjGYAh9+GI+8GRal7LK48/O81rrzoVIxcxvLN62TK2OhkQb8BInoMNvfyH8IAAAAASUVORK5CYII%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%0Athis._handleClick%20%3D%28%29%3D%3E%20%7B%0A%20%20%20cbu.setPrefs%28s%2C%20cbu.getPrefs%28s%29%20%3D%3D%20true%20%3F%20false%20%3A%20true%29%3B%0A%7D%3B%0Avar%20s%20%3D%20%22browser.tabs.remote.autostart%22%3B%0A%0Afunction%20toggleImage%28%29%20%7B%0A%20%20%20var%20val%20%3D%20cbu.getPrefs%28s%29%3B%0A%20%20%20var%20%7Bicon%7D%20%3D%20self%3B%0A%20%20%20icon.src%20%3D%20cbu.getPrefs%28s%29%20%3D%3D%20false%0A%20%20%20%3F%20self.image%0A%20%20%20%3A%20%22data%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAqNJREFUeNp8k09IFFEcx3/vzZudUVd3VsVsNUEhBOmUbBSh/blo1CEirGjzZh2kDaluHYSEbpFIghR18FBCHqJDFERIddMiqKBDkImr667urKszzsx7b3pv0TFraeDH+/f7fd73N7/fQ77vQ6lPC9fuChn1uwEh5JqLaaeQSZXyQ38DatqOnWw60T+gN8fjVDWquI8AOebaxuynz6nXoyMrX15NlAQgHNJaewZH6ruTfVlLB75eAAzbcE+rhCqNQvbt6MSvyVtXmGfn5T7Zcmg9P/SwrvtGIr1gAmY2ILH3IFFdPOubyANZy0HBJhA9OnDOR7ohMjslLqdYOhjN8eN1Ry4nMnPLgFwXfMaKFi3DReMbTnGNXQdscwUi8d6uipaOnkBBrKP3qmWJKbUD0cjncOZ+CqjYIGg7Z8o9CKk6RPZf6hcqnmJF1SsrGuOHvXULVGCgIQblCofEwUp4kYzBy2sxoC4LAKoAg2NBuKm9HYXCezApM+qARAzwXEBSOuXgOhTG35k7qiMh0lTggCgFNRTWFC3SQEAQmesBIoIs6UKuIgJcj/9T8zIsgqUYmScrTnzsWbm0Zy4sy78pFWypiGrbJdRF3tIwF1DGxSgUrWZsZuVSmDNvzfw+NaUgUgyWDnJkfyjwKQNFqtu8AAvf1R/vp31mzxXLmJ4Zv7uRnedYtM6WisELDQEg0Sn6gW4Gixy9fBaWZx7fE33Ag06s3ndxuKXrdlIcg+N4oGhkR/5SBVFVAKzB7Js7k9mPYz07AKKmJLL39FBTx/WbuhHD3PfEpTQAhNRycApLMPdh+FHu65MBEbda8jGp4YbO2razyarGA4coidZgQcYsbxbmp2ey356Nufmfz//7GoMDhGoQqagXU+zT9YzwWyzl91uAAQDUCFTmpTZ8qAAAAABJRU5ErkJggg%3D%3D%22%3B%20%0A%20%20%20self.tooltipText%20%3D%20val%20%3F%20%27%u0414%u0430%20%u041C%u0443%u043B%u044C%u0442%u0438%27%20%3A%20%27%u041D%u0435%u0442%20%u041C%u0443%u043B%u044C%u0442%u0438%27%3B%20%0A%7D%3B%0Athis.oncontextmenu%20%3De%3D%3E%20%7B%20e.button%20%26%26%20%21e.ctrlKey%20%26%26%20e.preventDefault%28%29%20%7D%3B%0AtoggleImage%28%29%3B%0AServices.prefs.addObserver%28%20s%2C%20toggleImage%2C%20false%20%29%3B%0AaddDestructor%28function%28%29%20%7B%20gPrefService.removeObserver%28%20s%2C%20toggleImage%2C%20false%20%29%20%7D%29%3B%20%20%0A%0A%0A%0A%0A%5D%5D%3E%3C/initcode%3E%0A%20%20%3Ccode%3E%3C%21%5BCDATA%5B/*CODE*/%5D%5D%3E%3C/code%3E%0A%20%20%3Caccelkey%3E%3C%21%5BCDATA%5B%5D%5D%3E%3C/accelkey%3E%0A%20%20%3Chelp%3E%3C%21%5BCDATA%5B%5D%5D%3E%3C/help%3E%0A%20%20%3Cattributes/%3E%0A%3C/custombutton%3E
Отредактировано solombala (18-12-2019 22:54:56)
Отсутствует
Dumby
Я не правильно обьяснил, эти 3 дополнения созданы лишь для одного.
Там при скачиваний .torrent файлов чтобы не выходило окошко, так как он не запоминает "запомнить".
Мне охота было вынести его из дополнения и применить как скрипт в каком нибудь скриптоприемнике, по идее если пашет в CB то можно и там попробывать)
-Просто не пойму 3 дополнения аж созданы для такого простого, но в тоже время нужного действия 2 из них старые один вроде поддерживается(все пашут).
Когда не легче ли скрипт, меня это давно коробит просто).. вот и хотел спросить а код вытащил с background.js вроде с .xpi.
-Проверил что-то не пашет у меня, да и ладно.
Вопрос просто такой реально ли вытащить или если нет то пусть будет лишнее дополнение, раз не перенесли его в скрипт наверно были причины, да и по вашим словам походу так и есть.
solombala и?
Отредактировано func4ptch4 (20-12-2019 18:37:15)
Отсутствует
Отсутствует
Dumby
Как бы теперь
уговорить
,что бы вот это заработало в 68й?
И вот без этой тяжело:
this._handleClick =()=> cbu.setPrefs(s, !cbu.getPrefs(s)); var s = 'CB.pasteIntoSearchBar'; cbu.isPref(s, true); toggleImage(); function toggleImage() self.checked = cbu.getPrefs(s); gPrefService.addObserver(s, toggleImage, false); addDestructor(()=> gPrefService.removeObserver(s, toggleImage) ); function pasteIntoSearchBar(e) { if ( e.button || !cbu.getPrefs(s) ) return; var sel = document.commandDispatcher.focusedWindow.getSelection(); if ( !sel.isCollapsed ) BrowserSearch.searchBar._textbox.value = sel; }; addEventListener('mouseup', pasteIntoSearchBar, false, gBrowser);
Отсутствует
Dumby подправь пожалуйста кнопку, что-то наворотил, не пойму где ошибка (срабатывает, если кнопку с кодом располагаю рядом со стандартной), делал на основе твоих кнопок
// Добавить на стандартную кнопку загрузки: средний клик - "Открыть в боковой панели", правый клик - в новой вкладке ........................................... (id => { var label = "CB Downloads"; var url = "chrome://browser/content/webext-panels.xul?" + id; var icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACE0lEQVQ4jY2RS0/bUBCFj3MdS44TnES2SZNlAFU0IlKlbukWqULtqum/7Lp0DzRqRQUqSqSGvAvKwq/4fe3rboobUqCMNJszZz4dzXBYq712++PW1va7VY1SalqmeRNR6pyeHL9anfHrgI0N+Xl7bw87O9vI5wVwHIckicu/rq/LZ2ffcXpyjEcBKWOQpAIkSUKSJACAXC4PTVXBrZvvBaQpgjDEdDpFGIaZLkkSGGP/B7A0hee68FwXvu9nuqZpiFnyhASMwXEcmKYJ13X/GnkeSfwEAPsDmM1mcBwn02VZzm7yKCBJkpzjOJjP57BtO9Pr9TrSe87IA8Du7otviqK8vBU9z8NisYBlWZnRsiyIYgH7+69TAAiC4Kbb/fIsBwB8nq81Gg2USkWUSkV4ngdKKRhjWVNKwXFAqVREo9EAIaQKAAQAlsvlOc/zH2RZJrZto9frQdf1O1F1XUelUkGxWMR4PIkuLs7fUEqvCABQSq8MQ+/m80JHUVUiiiIMw0AURdkHWq0WFFXFbDqLLi9/HPq+/zlLAABxHA9M0+wSQjra5iYpl8swDAOMMbTbbWzWapiMJ1G/3z8MAv/odo+sxozjeGDbVhfgOpqmkWq1CkVRoKoqRqNxNBj8PAyC4Gh15w7gFrJc2l/TNH2vqhoRxQKGw2E0Gg3fhmH46Z8/PlSCIBw0m0232WyGgiAcPOT7DVvzCQcpjgEOAAAAAElFTkSuQmCC"; var currentURL = "about:downloads"; var e = (name, attrs, node, append) => { var elm = document.createXULElement(name); for(var a in attrs) elm.setAttribute(a, attrs[a]); append ? node.append(elm) : node.before(elm); return elm; } var menuitem = e("menuitem", { label, type: "checkbox", id: "menu_CBDownloads", oncommand: `SidebarUI.toggle("${id}");`, }, document.getElementById("viewSidebarMenu"), true); var btn = e("toolbarbutton", { label, type: "checkbox", oncommand: "handleCommand();", id: "sidebar-switcher-CBDownloads", class: "subviewbutton subviewbutton-iconic" }, document.querySelector('toolbarbutton[id^="sidebar-switcher-"] + toolbarseparator')); SidebarUI.sidebars.set(id, { url, title: label, buttonId: btn.id, menuId: menuitem.id, }); var css = `\ #${btn.id} > .toolbarbutton-icon, #sidebar-box[sidebarcommand="${id}"] > #sidebar-header > #sidebar-switcher-target > #sidebar-icon { width: 16px; height: 16px; opacity: 0.8; fill: currentColor; -moz-context-properties: fill; list-style-image: url(${icon}); }`; var str = "data:text/css," + encodeURIComponent(css), type = windowUtils.USER_SHEET; windowUtils.loadSheetUsingURIString(str, type); addDestructor(() => { btn.remove(); menuitem.remove(); SidebarUI.sidebars.delete(id); windowUtils.removeSheetUsingURIString(str, type); }); var isActive = () => SidebarUI.isOpen && SidebarUI.currentID == id; if (isActive()) { SidebarUI.selectMenuItem(id); var doc = SidebarUI.browser.contentDocument; if (doc.readyState != "complete") return; var br = doc.getElementById("webext-panels-browser"); if (br) currentURL = currentURL; } btn.handleCommand = () => { if (!btn.hasAttribute("checked")) { SidebarUI._switcherPanel.hidePopup(); btn.setAttribute("checked", true); } loadURL(currentURL); } var btnn = document.getElementById("downloads-button"); var UpdateExt = function(event) { if (event.button != 1) return; event.preventDefault(); event.stopPropagation(); SidebarUI.toggle(id); } btnn.addEventListener("click", UpdateExt, false); var UpdateExt1 = function(event) { if (event.button != 2) return; event.preventDefault(); event.stopPropagation(); gBrowser.selectedTab = gBrowser. addTrustedTab ("about:downloads"); } btnn.addEventListener("click", UpdateExt1, false); addEventListener("load", e => e.target.documentURI == url && load(currentURL) , true, SidebarUI.browser); var loadURL = url => { currentURL = url; isActive() ? load(url) : SidebarUI.show(id); } var principal = {triggeringPrincipal: document.nodePrincipal}; var config = {browserStyle: false, extension: {remote: false}}; var e10sFox69 = Services.appinfo.browserTabsRemoteAutostart && parseInt(Services.appinfo.platformVersion) >= 69; var load = async url => { if (e10sFox69) { config.uri = url; config.extension.remote = E10SUtils.getRemoteTypeForURI(url, true) != E10SUtils.NOT_REMOTE; } var win = SidebarUI.browser.contentWindow; var br = win.document.getElementById("webext-panels-browser"); if (br) { if (br.currentURI.spec === url) return; br.parentNode.remove(); } var br = await win.getBrowser(config); win.onunload = () => currentURL = currentURL; br.loadURI(url, principal); } })("viewCBDownloads");
Отредактировано Andrey_Krropotkin (21-12-2019 22:20:06)
Отсутствует
что бы вот это заработало в 68й?
gBrowser удали (второй).
Не посмотришь,как починить?
Я фик знает, неремонтопригодно.
((id, code) => { var pref = "CB.pasteIntoSearchBar"; var checker = () => { var val = Services.prefs.getBoolPref(pref, false); this.checked = val; var has = id in g; val ? has || init() : has && destroy(); } Services.prefs.addObserver(pref, checker); this._handleClick = () => Services.prefs.setBoolPref( pref, !Services.prefs.getBoolPref(pref, false) ); var gs = "Cu.getGlobalForObject(Cu)", g = eval(gs); var psi, psd, fsi, fsd, receiver, vars = () => { var d = "data:,", ref = gs + "." + id, dref = d + ref; psi = dref + "=" + encodeURIComponent(code.replace("%MSG%", id)); psd = d + "delete " + ref; fsi = dref + ".init(this)"; fsd = dref + ".destroy(this)"; receiver = msg => {try { msg.target.ownerGlobal.windowRoot.ownerGlobal .BrowserSearch.searchBar._textbox.value = msg.data; } catch(ex) {}} vars = () => {} } var init = () => { vars(); Services.ppmm.loadProcessScript(psi, true); Services.mm.loadFrameScript(fsi, true); g[id].receiveMessage = receiver; Services.mm.addMessageListener(id, g[id]); } var destroy = () => { vars(); Services.mm.removeDelayedFrameScript(fsi); Services.ppmm.removeDelayedProcessScript(psi); Services.mm.loadFrameScript(fsd, false); Services.mm.removeMessageListener(id, g[id]); Services.ppmm.loadProcessScript(psd, false); } checker(); addDestructor(reason => { Services.prefs.removeObserver(pref, checker); reason[5] == "e" && id in g && destroy(); }); })("CB_ButtonCodeFragmentIdentifier_PasteIntoSearchBar", `{ init(cfmm) { cfmm.addEventListener("selectstart", this); cfmm.addEventListener("unload", this); }, destroy(cfmm) { cfmm.removeEventListener("selectstart", this); cfmm.removeEventListener("unload", this); }, handleEvent(e) { this[e.type](e); }, selectstart(e) { e.target.ownerGlobal.addEventListener( "mouseup", this, {once: true} ); }, mouseup(e) { var win = e.target.ownerGlobal; var sel = win.getSelection(); sel = !sel.isCollapsed && sel.toString(); /\\S/.test(sel) && win.docShell.messageManager .sendAsyncMessage("%MSG%", sel); }, unload(e) { this.destroy(e.target); } }`);
что-то наворотил, не пойму где ошибка
Ну как, если добавлять обработчики без удаления, то да, глюки возможны.
Да и зачем, если записать лучше ничуть не сложнее.
Рестарт. Если опять что-то не так, то не помешает описание проблемы,
в смысле что-нибудь более удобопонимаемое, чем
«срабатывает, если кнопку с кодом располагаю рядом со стандартной».
/* var btnn = document.getElementById("downloads-button"); var UpdateExt = function(event) { if (event.button != 1) return; event.preventDefault(); event.stopPropagation(); SidebarUI.toggle(id); } btnn.addEventListener("click", UpdateExt, false); var UpdateExt1 = function(event) { if (event.button != 2) return; event.preventDefault(); event.stopPropagation(); gBrowser.selectedTab = gBrowser. addTrustedTab ("about:downloads"); } btnn.addEventListener("click", UpdateExt1, false); */ addEventListener("auxclick", e => { if (e.button == 1) return SidebarUI.toggle(id); else if (e.ctrlKey || e.shiftKey) return; e.preventDefault(); gBrowser.selectedTab = gBrowser.addTrustedTab("about:downloads"); }, false, document.getElementById("downloads-button") || 1);
Отсутствует
выделенное никак не хочет появляться в поисковой строке
Ну не знаю, может настройка dom.select_events.enabled
переключена поперёк дефолтного значения.
Больше ничего в голову не приходит.
Отсутствует
solombala
Можно.
var id = "{ae3cc3e4-1091-48d0-91e0-446601bc2e22}"; AddonManager.getAddonByID(id).then( addon => addon[ addon.userDisabled ? "enable" : "disable" ]({allowSystemAddons: true}), Cu.reportError );
Отсутствует
Dumby
А теперь более сложное...Не могу ссылку передать сходу...Могу добавить в код отдельно(подставляю && !!gContextMenu.onVideo) , но ссылка не передается, копировать можно,а потом из буфера...
var contextMenu = document.getElementById("contentAreaContextMenu"); var menuitem = contextMenu.insertBefore(document.createXULElement("menuitem"), document.getElementById("context-savelink")); menuitem.setAttribute("label", "Открыть в " +sysPlayerName); menuitem.setAttribute("class", "menuitem-iconic"); menuitem.setAttribute("image", "moz-icon://file://" + path); menuitem.onclick = () => play(gContextMenu.linkURL); addEventListener("popupshowing", ()=> menuitem.hidden = !gContextMenu.onLink && !!gContextMenu.onVideo && !gContextMenu.onPlainTextLink, false, contextMenu); addDestructor(()=> menuitem.remove() ); var contextMenu = document.getElementById("contentAreaContextMenu"); var mItem = contextMenu.insertBefore(document.createXULElement("menuitem"), document.getElementById("context-copyvideourl")); mItem.setAttribute("label", openIn); mItem.onclick = () => { var vurl = gContextMenu.mediaURL, videoelem = gContextMenu.target; if(videoelem && videoelem.nodeName.toLowerCase() == 'video') { if(content.location.hostname.indexOf('youtu') != -1 && (tmp = content.location.toString().match(YoutubeID)) && tmp[1].length == 11) { play(vurl); videoMovedbox = content.document.createElement('videoMoved'); videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>'; loadURI(stopPl); content.document.getElementById('eow-title').appendChild(videoMovedbox); return; };
/*Initialization Code*/ var path = 'D:\\PotPlayer\\PotPlayer.exe' var sysPlayerName = "POTlayer"; var openIn = "Откыть в "+sysPlayerName; var videoMoved = "Видео перенесено в "+sysPlayerName; var noFound = "Не найдено видео на странице, доступное для переноса в "+sysPlayerName; var YoutubeID = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})(?:\W|$)/; if(!(cbu.getPrefs("CB.video")) || cbu.getPrefs("CB.video").length < 9) cbu.setPrefs("CB.video", "videotoplayer"); var tmp = '', tmpp = '', innerA = '<div style="display:block!important;color:#00ff00!important;width:250px!important;font:bold 16px serif!important;z-index:999!important;opacity:1!important;visibility: visible!important;', innerB = 'left:5px!important;position:absolute!important;height:auto!important;box-sizing:border-box!important;padding:5px!important;margin:5px!important;', stopPl = "javascript:(function(){v=document.getElementById('movie_player');if(v){v.stopVideo()}else{v=document.getElementsByTagName('video');if(v){v[0].src='';try{v[0].load()}catch(e){}};}})();", ytIMGouter = function(ytID) {return '<div width="100%"><br /><a target="_blank" href="https://www.youtube.com/watch?v=' + ytID + '"><img src="https://i.ytimg.com/vi/' + ytID + '/hqdefault.jpg"></a><br />' + innerA + 'background-color:black!important;position:relative!important;bottom:20px!important;"> ' + videoMoved + '</div><br /></div><br />'}, handlWin = function(currentWin) { tmp = ''; var elem = currentWin.document.getElementsByTagName('video'), currLoc = currentWin.location; if(elem.length > 0) { if(currLoc.hostname.indexOf('youtu') != -1 && (tmp = currLoc.toString().match(YoutubeID)) && tmp[1].length == 11) { play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); videoMovedbox = currentWin.document.createElement('videoMoved'); videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>'; loadURI(stopPl); currentWin.document.getElementById('eow-title').appendChild(videoMovedbox); return true; }; for(i = 0; i < elem.length; i++) { if(((tmp = getSrc(elem[i].parentNode, currLoc)) && tmp.length > 2) || (i == 0 && currentWin.document.body.innerHTML.substring(0, 7) == '<video ' && (tmp = currLoc.toString()))) { videoMovedbox = currentWin.document.createElement('videoMoved'); videoMovedbox.innerHTML = innerA + innerB + 'top:20px!important;background-color:black!important;">' + videoMoved + '</div>'; play(tmp); if(currLoc.hostname == 'www.youtube.com') { elem[i].parentNode.parentNode.appendChild(videoMovedbox); } else { elem[i].parentNode.appendChild(videoMovedbox); }; elem[i].src = ''; try { elem[i].load() } catch(e) {}; return true; } } }; currentWin._elems = currentWin.document.getElementsByTagName('iframe'); if(currentWin._elems.length > 0) { for(currentWin._iCounter = 0; currentWin._iCounter < currentWin._elems.length; currentWin._iCounter++) { if((currentWin._elems[currentWin._iCounter].src.indexOf('youtube.com') > -1) && (tmp = currentWin._elems[currentWin._iCounter].src.match(YoutubeID)) && (tmp[1].length == 11)) { play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); currentWin._elems[currentWin._iCounter].outerHTML = ytIMGouter(tmp[1]); return true; }; if(currentWin._elems[currentWin._iCounter].clientWidth > 80 && currentWin._elems[currentWin._iCounter].clientHeight > 40 && handlWin(currentWin._elems[currentWin._iCounter].contentWindow))return true; } }; elem = currentWin.document.getElementsByTagName('object'); currLoc = currentWin.location; if(elem.length == 0) { elem = currentWin.document.getElementsByTagName('embed') }; if(elem.length > 0) { for(i = 0; i < elem.length; i++) { if(elem[i].innerHTML.indexOf('youtu') != -1 && (tmp = elem[i].innerHTML.match(YoutubeID)) && tmp[1].length == 11) { play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); elem[i].outerHTML = ytIMGouter(tmp[1]); return true; } else { if(elem[i].clientWidth > 80 && elem[i].clientHeight > 40) { if(((tmp = getSrc(elem[i].parentNode, currLoc)) || (tmp = getLink(elem[i], currLoc))) && tmp.length > 2) { play(tmp); elem[i].outerHTML = innerA + 'background-color:black!important;bottom:20px!important;"> ' + videoMoved + '</div>'; return true; }; }; } }; }; return false; }; this.onclick = this.oncontextmenu = e => { if (e.target != this) return; if(e.button == 0) { if(cbu.getPrefs("CB.video").substring(0,6) == "videom"){ elem = content.document.getElementsByTagName('object'); if(elem.length == 0) { elem = content.document.getElementsByTagName('embed') }; resizeObjs(elem); resizeObjs(content.document.getElementsByTagName('iframe')); resizeObjs(content.document.getElementsByTagName('video')); } else { if(!handlWin(content))custombuttons.alertSlide1(noFound); } }; if ( e.button == 2 && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey ) { // ПКМ e.preventDefault(); var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile); file.initWithPath('D:\\PotPlayer\\PotPlayer.exe'); var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); var link = gClipboard.read(); var args = [link,"/play"]; process.init( file ); process.run( false, args, args.length ); } }; this.oncontextmenu = e => e.target != this ? menu.hasAttribute("context") : e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || ( e.detail != 1 ? menu.hidePopup() : !!menu.openPopup(this, "after_start") ); custombuttons.alertSlide1 = function(sTitle) { var as = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService); as.showAlertNotification('chrome://global/skin/icons/information-16.png', "", sTitle, false, "", null); setTimeout(() => as.closeAlert(), 999); }; this.tooltipText="Л: Видео в плеер\nП: Видео из Clipboard"; function resizeObjs(objs) { if(!objs) return; LEVELS = 3; dir = (cbu.getPrefs("CB.video") == "videomaximize") ? 1 : -1; for(i = 0; i < objs.length; i++) { var Width = new Array(LEVELS) var Height = new Array(LEVELS) Width[0] = objs[i].clientWidth; Height[0] = objs[i].clientHeight; if((Width[0] > (-20 * dir + 100)) && (Height[0] > (-20 * dir + 60))) { obj = objs[i]; for(var k = 1; ((k < LEVELS) && (obj.parentNode)); k++) { obj = obj.parentNode Width[k] = obj.clientWidth; Height[k] = obj.clientHeight; }; Width[0] = Width[0] + dir * (Width[0] / 5 | 0); Height[0] = Height[0] + dir * (Height[0] / 5 | 0); objs[i].style.width = Width[0] + "px"; objs[i].width = Width[0]; objs[i].style.height = Height[0] + "px"; objs[i].height = Height[0]; obj = objs[i]; for(var k = 1; ((k < LEVELS) && !(objs[i].tagName == 'IFRAME') && (obj.parentNode) && (Width[k]) && (Height[k]) && (Width[k] > (-20 * dir + 100)) && (Height[k] > (-20 * dir + 60))); k++) { obj = obj.parentNode Width[k] = Width[k] + dir * (Width[k] / 5 | 0); Height[k] = Height[k] + dir * (Height[k] / 5 | 0); obj.style.width = Width[k] + "px"; obj.width = Width[k]; obj.style.height = Height[k] + "px"; obj.height = Height[k]; } } }; }; function restProtHost(lnkR, curLoc) { if(lnkR.length==0)return ''; let tr = lnkR.replace(/^:\/\//, curLoc.protocol + "//"); if(!tr.match(/^https?:\/\//i)){ lnkR = tr.replace(/^\/+/, ''); if(lnkR.split('/')[0].split('?')[0].split('#')[0].toLowerCase().match(/^(?:[-a-z\d]+\.)+[a-z\d]{2,6}$/)){ tr = curLoc.protocol + '//' + lnkR; }else{ tr = curLoc.protocol + '//' + curLoc.host + "/" + lnkR; } }; return tr; }; function getSrc(vobj, currentLoc) { var t = '', tt = ''; if((((t = vobj.innerHTML.match(/<video.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i)) && (t) && (tt = t[1] || t[2] || t[3]) && tt.indexOf('blob:') == -1 ) || ((t = vobj.innerHTML.match(/<source.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*)).*?\stype=['"]?video\//i)) && (t) && (tt = t[1] || t[2] || t[3]))) && tt.length > 2 && tt.indexOf('blob:') == -1 ) { if(tt.indexOf(".mp4/?") == -1) { tt = tt.replace(/&/g, "&") }; t = restProtHost(tt, currentLoc); return t; }; return ''; }; function getLink(obj, curLocation) { if(!obj || !obj.tagName) return ''; var flashvars = '', // src = '', q = obj.tagName.toLowerCase(); var getParam = function(e, n) { var v = '', r = new RegExp('^(' + n + ')$', 'i'), param = e.getElementsByTagName('param'); for(var igp = 0, p; p = param[igp]; igp++) { if(p.hasAttribute('name') && p.getAttribute('name').match(r)) { v = p.getAttribute('value'); break }; }; return v; }; if(q == 'object') { // src = obj.getAttribute('data') || obj.getAttribute('src') || getParam(obj, 'movie|data|src|code|filename|url') || (obj.getElementsByTagName('embed').length > 0 ? obj.getElementsByTagName('embed')[0].getAttribute('src') : ''); flashvars = getParam(obj, 'flashvars'); } else if(q == 'embed') { // src = obj.getAttribute('src'); flashvars = obj.getAttribute('flashvars'); } else return ''; if(!flashvars) return ''; // src = restProtHost(src, curLocation); var restPath = function(f, s) { return(f.substring(0, 4) == 'http') ? f : s.replace(/[#?].*$/, '').replace(/[^\/]*$/, f) }; function videoLinkExtract(fl) { //alert(fl); var linkArr = [], outLinks = [], jj = 0, lba = '', lbb = '', decodeURL = gBrowser.currentURI.spec; { try { return decodeURIComponent(s) } catch(e) { return unescape(s) } }; for(var ij = 0; ij < 3; ij++) { lba = lba + String.fromCharCode(parseInt((Math.random() * 15 + 1) + '', 10)); lbb = lbb + String.fromCharCode(parseInt((Math.random() * 15 + 16) + '', 10)); }; function pushWithMerit(lnk) { var merit = -11; if(lnk.match(/^https?:\/\//i)) merit = merit + 40; if(outLinks.length == 0) merit = merit + 1; if(lnk.match(/^\//)) merit = merit + 7; if(lnk.match(/^\/\//)) merit = merit + 30; if(lnk.match(/240p([^a-z]|$)/i)) merit = merit + 1; if(lnk.match(/[^a-z]240([^a-z0-9]|$)/i)) merit = merit + 1; if(lnk.match(/360p([^a-z]|$)/i)) merit = merit + 3; if(lnk.match(/[^a-z]360([^a-z0-9]|$)/i)) merit = merit + 3; if(lnk.match(/480p([^a-z]|$)/i)) merit = merit + 5; if(lnk.match(/[^a-z]480([^a-z0-9]|$)/i)) merit = merit + 5; if(lnk.match(/720p([^a-z]|$)/i)) merit = merit + 7; if(lnk.match(/[^a-z]720([^a-z0-9]|$)/i)) merit = merit + 7; if(lnk.match(/\.mp4([^a-z]|$)/i)) merit = merit + 8; if(lnk.match(/_hd([^a-z]|$)/i)) merit = merit + 6; if(lnk.match(/\.(jpg|xml)([^a-z]|$)/i)) merit = merit - 40; if(merit > 0) outLinks.push(merit + lba + lnk); Services.console.logStringMessage('merit:'+merit+' lnk->'+lnk); }; linkArr.push(fl); while(linkArr.length > jj && jj < 30) { var testPaths = []; testPaths = linkArr[jj].split(/(\.(?:flv|mp4|m3u8))/i); if(testPaths[testPaths.length - 1] == '') testPaths.pop(); for(k = 1; k < testPaths.length; k = k + 2) { if(testPaths[k - 1].indexOf(lba) > -1) { pref = testPaths[k - 1]; } else { var testAboutDom = testPaths[k - 1].toLowerCase().split(/(https?:\/\/)/); if(testAboutDom[testAboutDom.length - 1]=='') testAboutDom.pop(); var pTest = testAboutDom[testAboutDom.length - 1].split(/(\?[^\?]*?&)/); if(pTest.length>2){ pTest.pop(); pTest.pop(); }; testAboutDom[testAboutDom.length - 1] = pTest.join(''); pref = testPaths[k - 1].substring(testAboutDom.join('').lastIndexOf("&") + 1); }; t2 = pref.lastIndexOf(lbb); if(t2 > -1) { pref = pref.substring(t2 + 3); } else { t2 = pref.lastIndexOf('{"'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.lastIndexOf('["'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.lastIndexOf(',"'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.toLowerCase().lastIndexOf('"http://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf('"https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(',http://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(',https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(';http'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf('*https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(' or '); if(t2 > -1) pref = pref.substring(t2 + 4); pref = pref.substring(pref.split('/')[0].toLowerCase().split('%2f')[0].lastIndexOf('=') + 1); } if(pref.length > 0) { if(pref.split('?')[0].toLowerCase().match(/%[2-3][0-9a-f]/)) { t2 = pref.indexOf('"') if(t2 > -1) pref = pref.substring(t2 + 1); suff = testPaths[k + 1] ? testPaths[k + 1].split('&')[0].split('"')[0].split(';')[0].split(/,http/i)[0] : ''; if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) { if(testPaths.length > k + 1) { testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length) }; t2 = pref.lastIndexOf(lba); if(t2 > -1) pref = pref.substring(t2 + 3) linkArr.push(decodeURL(pref + testPaths[k] + suff)); } else { testPaths[k + 1] = (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff } } else { suff = testPaths[k + 1] ? testPaths[k + 1].split(';')[0].split('"]')[0].split('"}')[0].split('",')[0].split(/,https?:\/\//i)[0].split('*https://')[0].split(' or ')[0] : ''; t2 = suff.indexOf('&'); if((t2 > -1) && (pref != testPaths[k - 1])) { if(t2 == 0) suff = ''; if(suff.charAt(0) != '?') suff = suff.split(/(&[^&]+=https?:\/\/)/i)[0]; }; if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) { if(testPaths.length > k + 1) { testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length) }; t2 = pref.lastIndexOf(lba); if(t2 > -1) pref = pref.substring(t2 + 3); pushWithMerit(pref + testPaths[k] + suff); } else { testPaths[k + 1] = lba + (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff } } } }; jj = jj + 1; }; if(outLinks.length == 0) return ''; function srt(a, b) { a = parseInt(a.substr(0, a.indexOf(lba)), 10); b = parseInt(b.substr(0, b.indexOf(lba)), 10); if(a < b) return 1; if(a > b) return -1; return 0 }; outLinks.sort(srt); outLinks[0] = outLinks[0].substr(outLinks[0].indexOf(lba) + 3) if(outLinks[0].indexOf('_hq.mp4/?time=') > 0) outLinks[0] = outLinks[0].replace(/&/g, '&'); return outLinks[0]; }; ol = videoLinkExtract(flashvars); if(!ol) return ''; // ol = ol.replace(/^:?\/\//, curLocation.protocol + "//"); // return restPath(ol, src); return restProtHost(ol, curLocation); }; var menu = self.appendChild(document.createXULElement("menupopup")); self.image = "moz-icon://file://" + path; var playerName = path.split("\\").pop().replace(".exe",""); self.label = "Открыть видео в " +sysPlayerName; setTimeout(() => { Menu_n_TooltipTxts.forEach((m) => { if("separator" in m) { menu.appendChild(document.createXULElement("menuseparator")); return }; var mItem = document.createXULElement("menuitem"); mItem.setAttribute("label", m.label); if("radio" in m) { mItem.setAttribute("type", "radio"); mItem.setAttribute('checked', cbu.getPrefs("CB.video") == m.value); if(cbu.getPrefs("CB.video") == m.value) { self.tooltipText = m.tooltipTxt; } mItem.onclick = () => { cbu.setPrefs("CB.video", m.value); tmp = (self.image == imgFlashToPlayer || self.image == imgFlashMinimize || self.image == imgFlashMaximize); if(m.value.substring(0,9)=='videotopl'){ self.image = tmp ? imgFlashToPlayer : imgHTML5ToPlayer; } else if(m.value=='videominimize') { self.image = tmp ? imgFlashMinimize : imgHTML5Minimize; } else self.image = tmp ? imgFlashMaximize : imgHTML5Maximize; self.tooltipText = m.tooltipTxt; }; } if("checkbox" in m) { mItem.setAttribute('type', 'checkbox'); mItem.setAttribute('checked', (self.image == imgFlashToPlayer || self.image == imgFlashMinimize || self.image == imgFlashMaximize )); mItem.onclick = function(e) { e.stopPropagation(); e.preventDefault(); if(e.button == 0) toggleFlash(); } } menu.appendChild(mItem); }); menu.onclick = function(e) { e.stopPropagation(); if(e.button > 0) e.preventDefault(); }; }, 100); var contextMenu = document.getElementById("contentAreaContextMenu"); var menuitem = contextMenu.insertBefore(document.createXULElement("menuitem"), document.getElementById("context-savelink")); menuitem.setAttribute("label", "Открыть в " +sysPlayerName); menuitem.setAttribute("class", "menuitem-iconic"); menuitem.setAttribute("image", "moz-icon://file://" + path); menuitem.onclick = () => play(gContextMenu.linkURL); addEventListener("popupshowing", ()=> menuitem.hidden = !gContextMenu.onLink && !gContextMenu.onPlainTextLink, false, contextMenu); addDestructor(()=> menuitem.remove() ); var contextMenu = document.getElementById("contentAreaContextMenu"); var mItem = contextMenu.insertBefore(document.createXULElement("menuitem"), document.getElementById("context-copyvideourl")); mItem.setAttribute("label", openIn); mItem.onclick = () => { var vurl = gContextMenu.mediaURL, videoelem = gContextMenu.target; if(videoelem && videoelem.nodeName.toLowerCase() == 'video') { if(content.location.hostname.indexOf('youtu') != -1 && (tmp = content.location.toString().match(YoutubeID)) && tmp[1].length == 11) { play(vurl); videoMovedbox = content.document.createElement('videoMoved'); videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>'; loadURI(stopPl); content.document.getElementById('eow-title').appendChild(videoMovedbox); return; }; if(content.location.hostname == 'www.youtube.com') { videoelem.parentNode.parentNode.appendChild(videoMovedbox); } else { var inFrameHref = inFrameWin.location.href, found = false; if(inFrameWin.location.hostname == 'www.youtube.com' && (tmp = inFrameHref.match(YoutubeID)) && tmp[1].length == 11){//и значит во фрейме elem = inFrameWin.parent.document.getElementsByTagName('iframe'); if(elem.length > 0) { for(i = 0; i < elem.length; i++) { if(elem[i].contentWindow == inFrameWin) { elem[i].outerHTML = ytIMGouter(tmp[1]); found = true; break; }; }; }; if(!found)inFrameWin.document.body.innerHTML = ytIMGouter(tmp[1]); return; }; videoelem.parentNode.appendChild(videoMovedbox); }; videoelem.src = ''; try { videoelem.load() } catch(e) {}; } else play(vurl); }; addEventListener("popupshowing", () => { mItem.hidden = !gContextMenu.onVideo || !gContextMenu.mediaURL; mItem2.hidden = !gContextMenu.linkURL; mItem3.hidden = framItem.hidden || gContextMenu.target.ownerDocument.location.hostname.indexOf('youtube.com') == -1; }, false, contextMenu); addDestructor(() => {mItem.remove();mItem2.remove();mItem3.remove()}); function play(link) { var file = Services.dirsvc.get('CurProcD', Ci.nsIFile); var MozExeDir = file.path.split('\\').slice(0,-1).join('\\'); file.initWithPath(path); if(!file.exists()) { custombuttons.alertBox("File not found!", MozExeDir + Path); return; }; var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); process.init(file); process.run(false, [link, cbu.getPrefs("CB.video") == "videotoplaylist" ? addToPlaylistKey : ""], 2); };
Ладно, сделал...См. где POt , лучше во внешнем редакторе , правильно путь прописать и будет праздник
/*Initialization Code*/ var path = 'D:\\PotPlayer\\PotPlayer.exe' var sysPlayerName = "POTlayer"; var openIn = "Откыть в "+sysPlayerName; var videoMoved = "Видео перенесено в "+sysPlayerName; var noFound = "Не найдено видео на странице, доступное для переноса в "+sysPlayerName; var YoutubeID = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})(?:\W|$)/; if(!(cbu.getPrefs("CB.video")) || cbu.getPrefs("CB.video").length < 9) cbu.setPrefs("CB.video", "videotoplayer"); var tmp = '', tmpp = '', innerA = '<div style="display:block!important;color:#00ff00!important;width:250px!important;font:bold 16px serif!important;z-index:999!important;opacity:1!important;visibility: visible!important;', innerB = 'left:5px!important;position:absolute!important;height:auto!important;box-sizing:border-box!important;padding:5px!important;margin:5px!important;', stopPl = "javascript:(function(){v=document.getElementById('movie_player');if(v){v.stopVideo()}else{v=document.getElementsByTagName('video');if(v){v[0].src='';try{v[0].load()}catch(e){}};}})();", ytIMGouter = function(ytID) {return '<div width="100%"><br /><a target="_blank" href="https://www.youtube.com/watch?v=' + ytID + '"><img src="https://i.ytimg.com/vi/' + ytID + '/hqdefault.jpg"></a><br />' + innerA + 'background-color:black!important;position:relative!important;bottom:20px!important;"> ' + videoMoved + '</div><br /></div><br />'}, handlWin = function(currentWin) { tmp = ''; var elem = currentWin.document.getElementsByTagName('video'), currLoc = currentWin.location; if(elem.length > 0) { if(currLoc.hostname.indexOf('youtu') != -1 && (tmp = currLoc.toString().match(YoutubeID)) && tmp[1].length == 11) { play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); videoMovedbox = currentWin.document.createElement('videoMoved'); videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>'; loadURI(stopPl); currentWin.document.getElementById('eow-title').appendChild(videoMovedbox); return true; }; for(i = 0; i < elem.length; i++) { if(((tmp = getSrc(elem[i].parentNode, currLoc)) && tmp.length > 2) || (i == 0 && currentWin.document.body.innerHTML.substring(0, 7) == '<video ' && (tmp = currLoc.toString()))) { videoMovedbox = currentWin.document.createElement('videoMoved'); videoMovedbox.innerHTML = innerA + innerB + 'top:20px!important;background-color:black!important;">' + videoMoved + '</div>'; play(tmp); if(currLoc.hostname == 'www.youtube.com') { elem[i].parentNode.parentNode.appendChild(videoMovedbox); } else { elem[i].parentNode.appendChild(videoMovedbox); }; elem[i].src = ''; try { elem[i].load() } catch(e) {}; return true; } } }; currentWin._elems = currentWin.document.getElementsByTagName('iframe'); if(currentWin._elems.length > 0) { for(currentWin._iCounter = 0; currentWin._iCounter < currentWin._elems.length; currentWin._iCounter++) { if((currentWin._elems[currentWin._iCounter].src.indexOf('youtube.com') > -1) && (tmp = currentWin._elems[currentWin._iCounter].src.match(YoutubeID)) && (tmp[1].length == 11)) { play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); currentWin._elems[currentWin._iCounter].outerHTML = ytIMGouter(tmp[1]); return true; }; if(currentWin._elems[currentWin._iCounter].clientWidth > 80 && currentWin._elems[currentWin._iCounter].clientHeight > 40 && handlWin(currentWin._elems[currentWin._iCounter].contentWindow))return true; } }; elem = currentWin.document.getElementsByTagName('object'); currLoc = currentWin.location; if(elem.length == 0) { elem = currentWin.document.getElementsByTagName('embed') }; if(elem.length > 0) { for(i = 0; i < elem.length; i++) { if(elem[i].innerHTML.indexOf('youtu') != -1 && (tmp = elem[i].innerHTML.match(YoutubeID)) && tmp[1].length == 11) { play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); elem[i].outerHTML = ytIMGouter(tmp[1]); return true; } else { if(elem[i].clientWidth > 80 && elem[i].clientHeight > 40) { if(((tmp = getSrc(elem[i].parentNode, currLoc)) || (tmp = getLink(elem[i], currLoc))) && tmp.length > 2) { play(tmp); elem[i].outerHTML = innerA + 'background-color:black!important;bottom:20px!important;"> ' + videoMoved + '</div>'; return true; }; }; } }; }; return false; }; this.onclick = this.oncontextmenu = e => { if (e.target != this) return; if(e.button == 0) { if(cbu.getPrefs("CB.video").substring(0,6) == "videom"){ elem = content.document.getElementsByTagName('object'); if(elem.length == 0) { elem = content.document.getElementsByTagName('embed') }; resizeObjs(elem); resizeObjs(content.document.getElementsByTagName('iframe')); resizeObjs(content.document.getElementsByTagName('video')); } else { if(!handlWin(content))custombuttons.alertSlide1(noFound); } }; if ( e.button == 2 && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey ) { // ПКМ e.preventDefault(); var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile); file.initWithPath('D:\\PotPlayer\\PotPlayer.exe'); var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); var link = gClipboard.read(); var args = [link,"/play"]; process.init( file ); process.run( false, args, args.length ); } }; this.oncontextmenu = e => e.target != this ? menu.hasAttribute("context") : e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || ( e.detail != 1 ? menu.hidePopup() : !!menu.openPopup(this, "after_start") ); custombuttons.alertSlide1 = function(sTitle) { var as = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService); as.showAlertNotification('chrome://global/skin/icons/information-16.png', "", sTitle, false, "", null); setTimeout(() => as.closeAlert(), 999); }; this.tooltipText="Л: Видео в плеер\nП: Видео из Clipboard"; function resizeObjs(objs) { if(!objs) return; LEVELS = 3; dir = (cbu.getPrefs("CB.video") == "videomaximize") ? 1 : -1; for(i = 0; i < objs.length; i++) { var Width = new Array(LEVELS) var Height = new Array(LEVELS) Width[0] = objs[i].clientWidth; Height[0] = objs[i].clientHeight; if((Width[0] > (-20 * dir + 100)) && (Height[0] > (-20 * dir + 60))) { obj = objs[i]; for(var k = 1; ((k < LEVELS) && (obj.parentNode)); k++) { obj = obj.parentNode Width[k] = obj.clientWidth; Height[k] = obj.clientHeight; }; Width[0] = Width[0] + dir * (Width[0] / 5 | 0); Height[0] = Height[0] + dir * (Height[0] / 5 | 0); objs[i].style.width = Width[0] + "px"; objs[i].width = Width[0]; objs[i].style.height = Height[0] + "px"; objs[i].height = Height[0]; obj = objs[i]; for(var k = 1; ((k < LEVELS) && !(objs[i].tagName == 'IFRAME') && (obj.parentNode) && (Width[k]) && (Height[k]) && (Width[k] > (-20 * dir + 100)) && (Height[k] > (-20 * dir + 60))); k++) { obj = obj.parentNode Width[k] = Width[k] + dir * (Width[k] / 5 | 0); Height[k] = Height[k] + dir * (Height[k] / 5 | 0); obj.style.width = Width[k] + "px"; obj.width = Width[k]; obj.style.height = Height[k] + "px"; obj.height = Height[k]; } } }; }; function restProtHost(lnkR, curLoc) { if(lnkR.length==0)return ''; let tr = lnkR.replace(/^:\/\//, curLoc.protocol + "//"); if(!tr.match(/^https?:\/\//i)){ lnkR = tr.replace(/^\/+/, ''); if(lnkR.split('/')[0].split('?')[0].split('#')[0].toLowerCase().match(/^(?:[-a-z\d]+\.)+[a-z\d]{2,6}$/)){ tr = curLoc.protocol + '//' + lnkR; }else{ tr = curLoc.protocol + '//' + curLoc.host + "/" + lnkR; } }; return tr; }; function getSrc(vobj, currentLoc) { var t = '', tt = ''; if((((t = vobj.innerHTML.match(/<video.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i)) && (t) && (tt = t[1] || t[2] || t[3]) && tt.indexOf('blob:') == -1 ) || ((t = vobj.innerHTML.match(/<source.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*)).*?\stype=['"]?video\//i)) && (t) && (tt = t[1] || t[2] || t[3]))) && tt.length > 2 && tt.indexOf('blob:') == -1 ) { if(tt.indexOf(".mp4/?") == -1) { tt = tt.replace(/&/g, "&") }; t = restProtHost(tt, currentLoc); return t; }; return ''; }; function getLink(obj, curLocation) { if(!obj || !obj.tagName) return ''; var flashvars = '', // src = '', q = obj.tagName.toLowerCase(); var getParam = function(e, n) { var v = '', r = new RegExp('^(' + n + ')$', 'i'), param = e.getElementsByTagName('param'); for(var igp = 0, p; p = param[igp]; igp++) { if(p.hasAttribute('name') && p.getAttribute('name').match(r)) { v = p.getAttribute('value'); break }; }; return v; }; if(q == 'object') { // src = obj.getAttribute('data') || obj.getAttribute('src') || getParam(obj, 'movie|data|src|code|filename|url') || (obj.getElementsByTagName('embed').length > 0 ? obj.getElementsByTagName('embed')[0].getAttribute('src') : ''); flashvars = getParam(obj, 'flashvars'); } else if(q == 'embed') { // src = obj.getAttribute('src'); flashvars = obj.getAttribute('flashvars'); } else return ''; if(!flashvars) return ''; // src = restProtHost(src, curLocation); var restPath = function(f, s) { return(f.substring(0, 4) == 'http') ? f : s.replace(/[#?].*$/, '').replace(/[^\/]*$/, f) }; function videoLinkExtract(fl) { //alert(fl); var linkArr = [], outLinks = [], jj = 0, lba = '', lbb = '', decodeURL = gBrowser.currentURI.spec; { try { return decodeURIComponent(s) } catch(e) { return unescape(s) } }; for(var ij = 0; ij < 3; ij++) { lba = lba + String.fromCharCode(parseInt((Math.random() * 15 + 1) + '', 10)); lbb = lbb + String.fromCharCode(parseInt((Math.random() * 15 + 16) + '', 10)); }; function pushWithMerit(lnk) { var merit = -11; if(lnk.match(/^https?:\/\//i)) merit = merit + 40; if(outLinks.length == 0) merit = merit + 1; if(lnk.match(/^\//)) merit = merit + 7; if(lnk.match(/^\/\//)) merit = merit + 30; if(lnk.match(/240p([^a-z]|$)/i)) merit = merit + 1; if(lnk.match(/[^a-z]240([^a-z0-9]|$)/i)) merit = merit + 1; if(lnk.match(/360p([^a-z]|$)/i)) merit = merit + 3; if(lnk.match(/[^a-z]360([^a-z0-9]|$)/i)) merit = merit + 3; if(lnk.match(/480p([^a-z]|$)/i)) merit = merit + 5; if(lnk.match(/[^a-z]480([^a-z0-9]|$)/i)) merit = merit + 5; if(lnk.match(/720p([^a-z]|$)/i)) merit = merit + 7; if(lnk.match(/[^a-z]720([^a-z0-9]|$)/i)) merit = merit + 7; if(lnk.match(/\.mp4([^a-z]|$)/i)) merit = merit + 8; if(lnk.match(/_hd([^a-z]|$)/i)) merit = merit + 6; if(lnk.match(/\.(jpg|xml)([^a-z]|$)/i)) merit = merit - 40; if(merit > 0) outLinks.push(merit + lba + lnk); Services.console.logStringMessage('merit:'+merit+' lnk->'+lnk); }; linkArr.push(fl); while(linkArr.length > jj && jj < 30) { var testPaths = []; testPaths = linkArr[jj].split(/(\.(?:flv|mp4|m3u8))/i); if(testPaths[testPaths.length - 1] == '') testPaths.pop(); for(k = 1; k < testPaths.length; k = k + 2) { if(testPaths[k - 1].indexOf(lba) > -1) { pref = testPaths[k - 1]; } else { var testAboutDom = testPaths[k - 1].toLowerCase().split(/(https?:\/\/)/); if(testAboutDom[testAboutDom.length - 1]=='') testAboutDom.pop(); var pTest = testAboutDom[testAboutDom.length - 1].split(/(\?[^\?]*?&)/); if(pTest.length>2){ pTest.pop(); pTest.pop(); }; testAboutDom[testAboutDom.length - 1] = pTest.join(''); pref = testPaths[k - 1].substring(testAboutDom.join('').lastIndexOf("&") + 1); }; t2 = pref.lastIndexOf(lbb); if(t2 > -1) { pref = pref.substring(t2 + 3); } else { t2 = pref.lastIndexOf('{"'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.lastIndexOf('["'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.lastIndexOf(',"'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.toLowerCase().lastIndexOf('"http://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf('"https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(',http://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(',https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(';http'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf('*https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(' or '); if(t2 > -1) pref = pref.substring(t2 + 4); pref = pref.substring(pref.split('/')[0].toLowerCase().split('%2f')[0].lastIndexOf('=') + 1); } if(pref.length > 0) { if(pref.split('?')[0].toLowerCase().match(/%[2-3][0-9a-f]/)) { t2 = pref.indexOf('"') if(t2 > -1) pref = pref.substring(t2 + 1); suff = testPaths[k + 1] ? testPaths[k + 1].split('&')[0].split('"')[0].split(';')[0].split(/,http/i)[0] : ''; if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) { if(testPaths.length > k + 1) { testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length) }; t2 = pref.lastIndexOf(lba); if(t2 > -1) pref = pref.substring(t2 + 3) linkArr.push(decodeURL(pref + testPaths[k] + suff)); } else { testPaths[k + 1] = (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff } } else { suff = testPaths[k + 1] ? testPaths[k + 1].split(';')[0].split('"]')[0].split('"}')[0].split('",')[0].split(/,https?:\/\//i)[0].split('*https://')[0].split(' or ')[0] : ''; t2 = suff.indexOf('&'); if((t2 > -1) && (pref != testPaths[k - 1])) { if(t2 == 0) suff = ''; if(suff.charAt(0) != '?') suff = suff.split(/(&[^&]+=https?:\/\/)/i)[0]; }; if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) { if(testPaths.length > k + 1) { testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length) }; t2 = pref.lastIndexOf(lba); if(t2 > -1) pref = pref.substring(t2 + 3); pushWithMerit(pref + testPaths[k] + suff); } else { testPaths[k + 1] = lba + (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff } } } }; jj = jj + 1; }; if(outLinks.length == 0) return ''; function srt(a, b) { a = parseInt(a.substr(0, a.indexOf(lba)), 10); b = parseInt(b.substr(0, b.indexOf(lba)), 10); if(a < b) return 1; if(a > b) return -1; return 0 }; outLinks.sort(srt); outLinks[0] = outLinks[0].substr(outLinks[0].indexOf(lba) + 3) if(outLinks[0].indexOf('_hq.mp4/?time=') > 0) outLinks[0] = outLinks[0].replace(/&/g, '&'); return outLinks[0]; }; ol = videoLinkExtract(flashvars); if(!ol) return ''; // ol = ol.replace(/^:?\/\//, curLocation.protocol + "//"); // return restPath(ol, src); return restProtHost(ol, curLocation); }; var menu = self.appendChild(document.createXULElement("menupopup")); self.image = "moz-icon://file://" + path; var playerName = path.split("\\").pop().replace(".exe",""); self.label = "Открыть видео в " +sysPlayerName; setTimeout(() => { Menu_n_TooltipTxts.forEach((m) => { if("separator" in m) { menu.appendChild(document.createXULElement("menuseparator")); return }; var mItem = document.createXULElement("menuitem"); mItem.setAttribute("label", m.label); if("radio" in m) { mItem.setAttribute("type", "radio"); mItem.setAttribute('checked', cbu.getPrefs("CB.video") == m.value); if(cbu.getPrefs("CB.video") == m.value) { self.tooltipText = m.tooltipTxt; } mItem.onclick = () => { cbu.setPrefs("CB.video", m.value); tmp = (self.image == imgFlashToPlayer || self.image == imgFlashMinimize || self.image == imgFlashMaximize); if(m.value.substring(0,9)=='videotopl'){ self.image = tmp ? imgFlashToPlayer : imgHTML5ToPlayer; } else if(m.value=='videominimize') { self.image = tmp ? imgFlashMinimize : imgHTML5Minimize; } else self.image = tmp ? imgFlashMaximize : imgHTML5Maximize; self.tooltipText = m.tooltipTxt; }; } if("checkbox" in m) { mItem.setAttribute('type', 'checkbox'); mItem.setAttribute('checked', (self.image == imgFlashToPlayer || self.image == imgFlashMinimize || self.image == imgFlashMaximize )); mItem.onclick = function(e) { e.stopPropagation(); e.preventDefault(); if(e.button == 0) toggleFlash(); } } menu.appendChild(mItem); }); menu.onclick = function(e) { e.stopPropagation(); if(e.button > 0) e.preventDefault(); }; }, 100); var contextMenu = document.getElementById("contentAreaContextMenu"); var menuitem = contextMenu.insertBefore(document.createXULElement("menuitem"), document.getElementById("context-savelink")); menuitem.setAttribute("label", "Открыть в " +sysPlayerName); menuitem.setAttribute("class", "menuitem-iconic"); menuitem.setAttribute("image", "moz-icon://file://" + path); menuitem.onclick = () => play(gContextMenu.linkURL || gContextMenu.mediaURL); addEventListener("popupshowing", ()=> menuitem.hidden = !gContextMenu.onLink && !gContextMenu.onVideo && !gContextMenu.onPlainTextLink , false, contextMenu); onclick = () => { var vurl = gContextMenu.mediaURL, videoelem = gContextMenu.target; if(videoelem && videoelem.nodeName.toLowerCase() == 'video') { if(content.location.hostname.indexOf('youtu') != -1 && (tmp = content.location.toString().match(YoutubeID)) && tmp[1].length == 11) { play(vurl); videoMovedbox = content.document.createElement('videoMoved'); videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>'; loadURI(stopPl); content.document.getElementById('eow-title').appendChild(videoMovedbox); return; }; if(content.location.hostname == 'www.youtube.com') { videoelem.parentNode.parentNode.appendChild(videoMovedbox); } else { var inFrameHref = inFrameWin.location.href, found = false; if(inFrameWin.location.hostname == 'www.youtube.com' && (tmp = inFrameHref.match(YoutubeID)) && tmp[1].length == 11){//и значит во фрейме elem = inFrameWin.parent.document.getElementsByTagName('iframe'); if(elem.length > 0) { for(i = 0; i < elem.length; i++) { if(elem[i].contentWindow == inFrameWin) { elem[i].outerHTML = ytIMGouter(tmp[1]); found = true; break; }; }; }; if(!found)inFrameWin.document.body.innerHTML = ytIMGouter(tmp[1]); return; }; videoelem.parentNode.appendChild(videoMovedbox); }; videoelem.src = ''; try { videoelem.load() } catch(e) {}; } else play(vurl); }; addEventListener("popupshowing", () => { mItem.hidden = !gContextMenu.onVideo || !gContextMenu.mediaURL; mItem2.hidden = !gContextMenu.linkURL; mItem3.hidden = framItem.hidden || gContextMenu.target.ownerDocument.location.hostname.indexOf('youtube.com') == -1; }, false, contextMenu); addDestructor(() => {mItem.remove();mItem2.remove();mItem3.remove()}); function play(link) { var file = Services.dirsvc.get('CurProcD', Ci.nsIFile); var MozExeDir = file.path.split('\\').slice(0,-1).join('\\'); file.initWithPath(path); if(!file.exists()) { custombuttons.alertBox("File not found!", MozExeDir + Path); return; }; var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); process.init(file); process.run(false, [link, cbu.getPrefs("CB.video") == "videotoplaylist" ? addToPlaylistKey : ""], 2); };
Отредактировано solombala (24-12-2019 16:11:59)
Отсутствует
solombala
А можно сделать еще один пункт в меню кнопки: Добавить в плейлист. Как раньше было.
/*Initialization Code*/ var path = "c:\\INstaLL\\PotPlayer\\PotPlayerMini.exe"; var addToPlaylistKey = "/add"; var sysPlayerName = "POTPlayer"; var openIn = "Откыть в "+sysPlayerName; var videoMoved = "Видео перенесено в "+sysPlayerName; var noFound = "Не найдено видео на странице, доступное для переноса в "+sysPlayerName; var Menu_n_TooltipTxts = [{ label: "Действие кнопки: Запустить видео сразу в "+sysPlayerName, radio: '', value: 'videotoplayer', tooltipTxt: 'Запустить видео сразу в '+sysPlayerName }, { label: "Действие кнопки: Перенести видео в плейлист "+sysPlayerName, radio: '', value: 'videotoplaylist', tooltipTxt: 'Перенести видео в плейлист '+sysPlayerName }, ]; var YoutubeID = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})(?:\W|$)/; if(!(cbu.getPrefs("CB.videoout.action")) || cbu.getPrefs("CB.videoout.action").length < 9) cbu.setPrefs("CB.videoout.action", "videotoplayer"); var tmp = '', tmpp = '', innerA = '<div style="display:block!important;color:#00ff00!important;width:250px!important;font:bold 16px serif!important;z-index:999!important;opacity:1!important;visibility: visible!important;', innerB = 'left:5px!important;position:absolute!important;height:auto!important;box-sizing:border-box!important;padding:5px!important;margin:5px!important;', stopPl = "javascript:(function(){v=document.getElementById('movie_player');if(v){v.stopVideo()}else{v=document.getElementsByTagName('video');if(v){v[0].src='';try{v[0].load()}catch(e){}};}})();", ytIMGouter = function(ytID) {return '<div width="100%"><br /><a target="_blank" href="https://www.youtube.com/watch?v=' + ytID + '"><img src="https://i.ytimg.com/vi/' + ytID + '/hqdefault.jpg"></a><br />' + innerA + 'background-color:black!important;position:relative!important;bottom:20px!important;"> ' + videoMoved + '</div><br /></div><br />'}, handlWin = function(currentWin) { tmp = ''; var elem = currentWin.document.getElementsByTagName('video'), currLoc = currentWin.location; if(elem.length > 0) { if(currLoc.hostname.indexOf('youtu') != -1 && (tmp = currLoc.toString().match(YoutubeID)) && tmp[1].length == 11) { play(cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); videoMovedbox = currentWin.document.createElementNS(xulns,"videoMoved"); videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>'; loadURI(stopPl); currentWin.document.getElementById('eow-title').appendChild(videoMovedbox); return true; }; for(i = 0; i < elem.length; i++) { if(((tmp = getSrc(elem[i].parentNode, currLoc)) && tmp.length > 2) || (i == 0 && currentWin.document.body.innerHTML.substring(0, 7) == '<video ' && (tmp = currLoc.toString()))) { videoMovedbox = currentWin.document.createElementNS(xulns,"videoMoved"); videoMovedbox.innerHTML = innerA + innerB + 'top:20px!important;background-color:black!important;">' + videoMoved + '</div>'; play(tmp); if(currLoc.hostname == 'www.youtube.com') { elem[i].parentNode.parentNode.appendChild(videoMovedbox); } else { elem[i].parentNode.appendChild(videoMovedbox); }; elem[i].src = ''; try { elem[i].load() } catch(e) {}; return true; } } }; currentWin._elems = currentWin.document.getElementsByTagName('iframe'); if(currentWin._elems.length > 0) { for(currentWin._iCounter = 0; currentWin._iCounter < currentWin._elems.length; currentWin._iCounter++) { if((currentWin._elems[currentWin._iCounter].src.indexOf('youtube.com') > -1) && (tmp = currentWin._elems[currentWin._iCounter].src.match(YoutubeID)) && (tmp[1].length == 11)) { play(cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); currentWin._elems[currentWin._iCounter].outerHTML = ytIMGouter(tmp[1]); return true; }; if(currentWin._elems[currentWin._iCounter].clientWidth > 80 && currentWin._elems[currentWin._iCounter].clientHeight > 40 && handlWin(currentWin._elems[currentWin._iCounter].contentWindow))return true; } }; elem = currentWin.document.getElementsByTagName('object'); currLoc = currentWin.location; if(elem.length == 0) { elem = currentWin.document.getElementsByTagName('embed') }; if(elem.length > 0) { for(i = 0; i < elem.length; i++) { if(elem[i].innerHTML.indexOf('youtu') != -1 && (tmp = elem[i].innerHTML.match(YoutubeID)) && tmp[1].length == 11) { play(cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]); elem[i].outerHTML = ytIMGouter(tmp[1]); return true; } else { if(elem[i].clientWidth > 80 && elem[i].clientHeight > 40) { if(((tmp = getSrc(elem[i].parentNode, currLoc)) || (tmp = getLink(elem[i], currLoc))) && tmp.length > 2) { play(tmp); elem[i].outerHTML = innerA + 'background-color:black!important;bottom:20px!important;"> ' + videoMoved + '</div>'; return true; }; }; } }; }; return false; }; this.onclick = this.oncontextmenu = e => { if (e.target != this) return; if(e.button == 0) { if(cbu.getPrefs("CB.videoout.action").substring(0,6) == "videom"){ elem = content.document.getElementsByTagName('object'); if(elem.length == 0) { elem = content.document.getElementsByTagName('embed') }; resizeObjs(elem); resizeObjs(content.document.getElementsByTagName('iframe')); resizeObjs(content.document.getElementsByTagName('video')); } else { if(!handlWin(content))custombuttons.alertSlide1(noFound); } }; if(e.button == 1) gShowPopup(self); }; this.oncontextmenu = e => e.target != this ? menu.hasAttribute("context") : e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || ( e.detail != 1 ? menu.hidePopup() : !!menu.openPopup(this, "after_start") ); custombuttons.alertSlide1 = function(sTitle) { var as = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService); as.showAlertNotification('chrome://global/skin/icons/information-16.png', "", sTitle, false, "", null); setTimeout(() => as.closeAlert(), 999); }; function resizeObjs(objs) { if(!objs) return; LEVELS = 3; dir = (cbu.getPrefs("CB.videoout.action") == "videomaximize") ? 1 : -1; for(i = 0; i < objs.length; i++) { var Width = new Array(LEVELS) var Height = new Array(LEVELS) Width[0] = objs[i].clientWidth; Height[0] = objs[i].clientHeight; if((Width[0] > (-20 * dir + 100)) && (Height[0] > (-20 * dir + 60))) { obj = objs[i]; for(var k = 1; ((k < LEVELS) && (obj.parentNode)); k++) { obj = obj.parentNode Width[k] = obj.clientWidth; Height[k] = obj.clientHeight; }; Width[0] = Width[0] + dir * (Width[0] / 5 | 0); Height[0] = Height[0] + dir * (Height[0] / 5 | 0); objs[i].style.width = Width[0] + "px"; objs[i].width = Width[0]; objs[i].style.height = Height[0] + "px"; objs[i].height = Height[0]; obj = objs[i]; for(var k = 1; ((k < LEVELS) && !(objs[i].tagName == 'IFRAME') && (obj.parentNode) && (Width[k]) && (Height[k]) && (Width[k] > (-20 * dir + 100)) && (Height[k] > (-20 * dir + 60))); k++) { obj = obj.parentNode Width[k] = Width[k] + dir * (Width[k] / 5 | 0); Height[k] = Height[k] + dir * (Height[k] / 5 | 0); obj.style.width = Width[k] + "px"; obj.width = Width[k]; obj.style.height = Height[k] + "px"; obj.height = Height[k]; } } }; }; function restProtHost(lnkR, curLoc) { if(lnkR.length==0)return ''; let tr = lnkR.replace(/^:\/\//, curLoc.protocol + "//"); if(!tr.match(/^https?:\/\//i)){ lnkR = tr.replace(/^\/+/, ''); if(lnkR.split('/')[0].split('?')[0].split('#')[0].toLowerCase().match(/^(?:[-a-z\d]+\.)+[a-z\d]{2,6}$/)){ tr = curLoc.protocol + '//' + lnkR; }else{ tr = curLoc.protocol + '//' + curLoc.host + "/" + lnkR; } }; return tr; }; function getSrc(vobj, currentLoc) { var t = '', tt = ''; if((((t = vobj.innerHTML.match(/<video.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i)) && (t) && (tt = t[1] || t[2] || t[3]) && tt.indexOf('blob:') == -1 ) || ((t = vobj.innerHTML.match(/<source.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*)).*?\stype=['"]?video\//i)) && (t) && (tt = t[1] || t[2] || t[3]))) && tt.length > 2 && tt.indexOf('blob:') == -1 ) { if(tt.indexOf(".mp4/?") == -1) { tt = tt.replace(/&/g, "&") }; t = restProtHost(tt, currentLoc); return t; }; return ''; }; function getLink(obj, curLocation) { if(!obj || !obj.tagName) return ''; var flashvars = '', // src = '', q = obj.tagName.toLowerCase(); var getParam = function(e, n) { var v = '', r = new RegExp('^(' + n + ')$', 'i'), param = e.getElementsByTagName('param'); for(var igp = 0, p; p = param[igp]; igp++) { if(p.hasAttribute('name') && p.getAttribute('name').match(r)) { v = p.getAttribute('value'); break }; }; return v; }; if(q == 'object') { // src = obj.getAttribute('data') || obj.getAttribute('src') || getParam(obj, 'movie|data|src|code|filename|url') || (obj.getElementsByTagName('embed').length > 0 ? obj.getElementsByTagName('embed')[0].getAttribute('src') : ''); flashvars = getParam(obj, 'flashvars'); } else if(q == 'embed') { // src = obj.getAttribute('src'); flashvars = obj.getAttribute('flashvars'); } else return ''; if(!flashvars) return ''; // src = restProtHost(src, curLocation); var restPath = function(f, s) { return(f.substring(0, 4) == 'http') ? f : s.replace(/[#?].*$/, '').replace(/[^\/]*$/, f) }; function videoLinkExtract(fl) { //alert(fl); var linkArr = [], outLinks = [], jj = 0, lba = '', lbb = '', decodeURL = function(s) { try { return decodeURIComponent(s) } catch(e) { return unescape(s) } }; for(var ij = 0; ij < 3; ij++) { lba = lba + String.fromCharCode(parseInt((Math.random() * 15 + 1) + '', 10)); lbb = lbb + String.fromCharCode(parseInt((Math.random() * 15 + 16) + '', 10)); }; function pushWithMerit(lnk) { var merit = -11; if(lnk.match(/^https?:\/\//i)) merit = merit + 40; if(outLinks.length == 0) merit = merit + 1; if(lnk.match(/^\//)) merit = merit + 7; if(lnk.match(/^\/\//)) merit = merit + 30; if(lnk.match(/240p([^a-z]|$)/i)) merit = merit + 1; if(lnk.match(/[^a-z]240([^a-z0-9]|$)/i)) merit = merit + 1; if(lnk.match(/360p([^a-z]|$)/i)) merit = merit + 3; if(lnk.match(/[^a-z]360([^a-z0-9]|$)/i)) merit = merit + 3; if(lnk.match(/480p([^a-z]|$)/i)) merit = merit + 5; if(lnk.match(/[^a-z]480([^a-z0-9]|$)/i)) merit = merit + 5; if(lnk.match(/720p([^a-z]|$)/i)) merit = merit + 7; if(lnk.match(/[^a-z]720([^a-z0-9]|$)/i)) merit = merit + 7; if(lnk.match(/\.mp4([^a-z]|$)/i)) merit = merit + 8; if(lnk.match(/_hd([^a-z]|$)/i)) merit = merit + 6; if(lnk.match(/\.(jpg|xml)([^a-z]|$)/i)) merit = merit - 40; if(merit > 0) outLinks.push(merit + lba + lnk); Services.console.logStringMessage('merit:'+merit+' lnk->'+lnk); }; linkArr.push(fl); while(linkArr.length > jj && jj < 30) { var testPaths = []; testPaths = linkArr[jj].split(/(\.(?:flv|mp4|m3u8))/i); if(testPaths[testPaths.length - 1] == '') testPaths.pop(); for(k = 1; k < testPaths.length; k = k + 2) { if(testPaths[k - 1].indexOf(lba) > -1) { pref = testPaths[k - 1]; } else { var testAboutDom = testPaths[k - 1].toLowerCase().split(/(https?:\/\/)/); if(testAboutDom[testAboutDom.length - 1]=='') testAboutDom.pop(); var pTest = testAboutDom[testAboutDom.length - 1].split(/(\?[^\?]*?&)/); if(pTest.length>2){ pTest.pop(); pTest.pop(); }; testAboutDom[testAboutDom.length - 1] = pTest.join(''); pref = testPaths[k - 1].substring(testAboutDom.join('').lastIndexOf("&") + 1); }; t2 = pref.lastIndexOf(lbb); if(t2 > -1) { pref = pref.substring(t2 + 3); } else { t2 = pref.lastIndexOf('{"'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.lastIndexOf('["'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.lastIndexOf(',"'); if(t2 > -1) pref = pref.substring(t2 + 2); t2 = pref.toLowerCase().lastIndexOf('"http://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf('"https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(',http://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(',https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(';http'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf('*https://'); if(t2 > -1) pref = pref.substring(t2 + 1); t2 = pref.toLowerCase().lastIndexOf(' or '); if(t2 > -1) pref = pref.substring(t2 + 4); pref = pref.substring(pref.split('/')[0].toLowerCase().split('%2f')[0].lastIndexOf('=') + 1); } if(pref.length > 0) { if(pref.split('?')[0].toLowerCase().match(/%[2-3][0-9a-f]/)) { t2 = pref.indexOf('"') if(t2 > -1) pref = pref.substring(t2 + 1); suff = testPaths[k + 1] ? testPaths[k + 1].split('&')[0].split('"')[0].split(';')[0].split(/,http/i)[0] : ''; if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) { if(testPaths.length > k + 1) { testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length) }; t2 = pref.lastIndexOf(lba); if(t2 > -1) pref = pref.substring(t2 + 3) linkArr.push(decodeURL(pref + testPaths[k] + suff)); } else { testPaths[k + 1] = (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff } } else { suff = testPaths[k + 1] ? testPaths[k + 1].split(';')[0].split('"]')[0].split('"}')[0].split('",')[0].split(/,https?:\/\//i)[0].split('*https://')[0].split(' or ')[0] : ''; t2 = suff.indexOf('&'); if((t2 > -1) && (pref != testPaths[k - 1])) { if(t2 == 0) suff = ''; if(suff.charAt(0) != '?') suff = suff.split(/(&[^&]+=https?:\/\/)/i)[0]; }; if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) { if(testPaths.length > k + 1) { testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length) }; t2 = pref.lastIndexOf(lba); if(t2 > -1) pref = pref.substring(t2 + 3); pushWithMerit(pref + testPaths[k] + suff); } else { testPaths[k + 1] = lba + (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff } } } }; jj = jj + 1; }; if(outLinks.length == 0) return ''; function srt(a, b) { a = parseInt(a.substr(0, a.indexOf(lba)), 10); b = parseInt(b.substr(0, b.indexOf(lba)), 10); if(a < b) return 1; if(a > b) return -1; return 0 }; outLinks.sort(srt); outLinks[0] = outLinks[0].substr(outLinks[0].indexOf(lba) + 3) if(outLinks[0].indexOf('_hq.mp4/?time=') > 0) outLinks[0] = outLinks[0].replace(/&/g, '&'); return outLinks[0]; }; ol = videoLinkExtract(flashvars); if(!ol) return ''; // ol = ol.replace(/^:?\/\//, curLocation.protocol + "//"); // return restPath(ol, src); return restProtHost(ol, curLocation); }; var menu = self.appendChild(document.createElementNS(xulns,"menupopup")); self.image = "moz-icon://file://" + path; var playerName = path.split("\\").pop().replace(".exe",""); self.label = "Открыть видео в " +sysPlayerName; setTimeout(() => { Menu_n_TooltipTxts.forEach((m) => { if("separator" in m) { menu.appendChild(document.createElementNS(xulns,"menuseparator")); return }; var mItem = document.createElementNS(xulns,"menuitem"); mItem.setAttribute("label", m.label); if("radio" in m) { mItem.setAttribute("type", "radio"); mItem.setAttribute('checked', cbu.getPrefs("CB.videoout.action") == m.value); if(cbu.getPrefs("CB.videoout.action") == m.value) { self.tooltipText = m.tooltipTxt; } mItem.onclick = () => { cbu.setPrefs("CB.videoout.action", m.value); tmp = (self.image == imgFlashToPlayer || self.image == imgFlashMinimize || self.image == imgFlashMaximize); if(m.value.substring(0,9)=='videotopl'){ self.image = tmp ? imgFlashToPlayer : imgHTML5ToPlayer; } else if(m.value=='videominimize') { self.image = tmp ? imgFlashMinimize : imgHTML5Minimize; } else self.image = tmp ? imgFlashMaximize : imgHTML5Maximize; self.tooltipText = m.tooltipTxt; }; } if("checkbox" in m) { mItem.setAttribute('type', 'checkbox'); mItem.setAttribute('checked', (self.image == imgFlashToPlayer || self.image == imgFlashMinimize || self.image == imgFlashMaximize )); mItem.onclick = function(e) { e.stopPropagation(); e.preventDefault(); if(e.button == 0) toggleFlash(); } } menu.appendChild(mItem); }); menu.onclick = function(e) { e.stopPropagation(); if(e.button > 0) e.preventDefault(); }; }, 100); var contextMenu = document.getElementById("contentAreaContextMenu"); var menuitem = contextMenu.insertBefore(document.createElementNS(xulns,"menuitem"), document.getElementById("context-sep-open")); menuitem.setAttribute("label", "Перенести в " +sysPlayerName); menuitem.setAttribute("class", "menuitem-iconic"); menuitem.setAttribute("image", "moz-icon://file://" + path); menuitem.onclick = () => play(gContextMenu.linkURL); addEventListener("popupshowing", ()=> menuitem.hidden = !gContextMenu.onLink, false, contextMenu); addDestructor(()=> menuitem.remove() ); var contextMenu = document.getElementById("contentAreaContextMenu"); var mItem = contextMenu.insertBefore(document.createElementNS("xulns,menuitem"), document.getElementById("context-copyvideourl")); mItem.setAttribute("label", openIn); mItem.onclick = () => { var vurl = gContextMenu.mediaURL, videoelem = gContextMenu.target; if(videoelem && videoelem.nodeName.toLowerCase() == 'video') { if(content.location.hostname.indexOf('youtu') != -1 && (tmp = content.location.toString().match(YoutubeID)) && tmp[1].length == 11) { play(vurl); videoMovedbox = content.document.createElementNS(xulns,"videoMoved"); videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>'; loadURI(stopPl); content.document.getElementById('eow-title').appendChild(videoMovedbox); return; }; if(content.location.hostname == 'www.youtube.com') { videoelem.parentNode.parentNode.appendChild(videoMovedbox); } else { var inFrameHref = inFrameWin.location.href, found = false; if(inFrameWin.location.hostname == 'www.youtube.com' && (tmp = inFrameHref.match(YoutubeID)) && tmp[1].length == 11){//и значит во фрейме elem = inFrameWin.parent.document.getElementsByTagName('iframe'); if(elem.length > 0) { for(i = 0; i < elem.length; i++) { if(elem[i].contentWindow == inFrameWin) { elem[i].outerHTML = ytIMGouter(tmp[1]); found = true; break; }; }; }; if(!found)inFrameWin.document.body.innerHTML = ytIMGouter(tmp[1]); return; }; videoelem.parentNode.appendChild(videoMovedbox); }; videoelem.src = ''; try { videoelem.load() } catch(e) {}; } else play(vurl); }; addEventListener("popupshowing", () => { mItem.hidden = !gContextMenu.onVideo || !gContextMenu.mediaURL; mItem2.hidden = !gContextMenu.linkURL; mItem3.hidden = framItem.hidden || gContextMenu.target.ownerDocument.location.hostname.indexOf('youtube.com') == -1; }, false, contextMenu); addDestructor(() => {mItem.remove();mItem2.remove();mItem3.remove()}); function play(link) { var file = Services.dirsvc.get('CurProcD', Ci.nsIFile); var MozExeDir = file.path.split('\\').slice(0,-1).join('\\'); file.initWithPath(path); if(!file.exists()) { custombuttons.alertBox("File not found!", MozExeDir + Path); return; }; var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); process.init(file); process.run(false, [link, cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? addToPlaylistKey : ""], 2); };
Отредактировано Garalf (24-12-2019 18:25:31)
Отсутствует
Garalf
Не могу . Третей кнопки нет. Только без переключения. Или из буфера, или все в плейлист. Смени в самом низу.
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); var args = [link,"/add"]; process.init( file ); process.run( false, args, args.length ); };
Отсутствует
Можно эту кнопку починить?, надо без клика просто чтобы возле него появлялись новые, сломался с 70+ вроде.
/*Initialization*/ //this._handleClick=()=>{self.checked=!self.checked;document.persist(self.id,"checked");}; var observer={observe:button=>{ //if(!self.checked)return; var toolbar=self.parentNode; toolbar.insertBefore(button,self.nextSibling); custombuttons.persistCurrentSets(toolbar.id,_id,button.id); if(parseInt(Services.appinfo.version)<43)return; function observer(subject,topic,data){setTimeout(()=> Services.ww.unregisterNotification(observer),500);subject.close();}; Services.ww.registerNotification(observer);}}; var notificationPrefix=custombuttons.notificationPrefix+"installButton"; Services.obs.addObserver(observer,notificationPrefix,false); addDestructor(()=>Services.obs.removeObserver(observer,notificationPrefix));
Отредактировано func4ptch4 (26-12-2019 18:11:44)
Отсутствует
xrun1, каким методом делал?
Отсутствует
func4ptch4
method 1
Где-то уже говорил на форуме,
что это надо класть в самый конец userChrome.css. У меня, например, не загружались некоторые .css, которые шли импортом ниже этой строки. Да, и это моя папка "other" с файлом userChrome.xml, проверяйте путь у себя.
<?xml version="1.0"?> <bindings id="generalBindings" xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl"> <binding id="js"> <implementation> <constructor> <![CDATA[ function load_js_script(js_file_name) { Services.scriptloader.loadSubScript(Components.stack.filename.substring(0, Components.stack.filename.lastIndexOf("/") + 1) + js_file_name, window); } load_js_script("custom_scrollbars.uc.js"); load_js_script("password_manager_button.uc.js"); load_js_script("tabstoolbar_doubleclickontab_reloadtab.uc.js"); // load_js_script("password_manager_button_v2.uc.js"); ]]> </constructor> </implementation> </binding> </bindings>
Отсутствует
xrun1, проверил твой скрипты работают, а вот более сложные нет... или их не обновляли давно и в коде ошибки, но странно в 70 они работают... и от .XBL вроде откажутся в 72, так что этот метод уже совсем скоро не будет работать, да и другие наверно...
Отредактировано func4ptch4 (27-12-2019 03:51:37)
Отсутствует