egorsemenov06
Попробуйте по тексту скрипта найти ucf_custom_script_win и заменить на ucf_custom_scripts_win и ucf_custom_script_all_win на ucf_custom_scripts_all_win.
ЗЫ: Так на шару, авось повезёт...
<Большое СПАСИБО первые две кнопки заработали
Dumby еще вот этот код не работает на 133.0
https://forum.mozilla-russia.org/viewto … 95#p811495
и переводчик гугл
// Google Translate в контекстном меню....... (this.googletranslate = { init(that) { var lc = navigator.lastClick = {}, w = null, xhtmlns = 'http://www.w3.org/1999/xhtml'; var mouseUp = (e) => { if (e.button) return; lc.X = e.screenX - mozInnerScreenX; lc.Y = e.screenY - mozInnerScreenY; }; gBrowser.tabpanels.addEventListener('mouseup', mouseUp, false); this.destructor = () => { gBrowser.tabpanels.removeEventListener('mouseup', mouseUp, false); if (w) w.closeWin(); }; that.unloadlisteners.push("googletranslate"); var createWindow = function(text, status, title, id, pos, size) { var win = window, doc = win.document, wId = 'ujs_window'+(id || ''); w = doc.getElementById(wId); var keyDown = function(e) {if (!e.shiftKey && !e.ctrlKey && !e.altKey && e.keyCode == 27)doc.getElementById(wId).closeWin();}; var mouseDown = function() {doc.getElementById(wId).closeWin();}; if (w) w.closeWin(); w = doc.createElementNS(xhtmlns, 'div'); w.setAttribute('style', 'position:fixed;display:block;visibility:hidden;left:0;top:0;width:auto;height:auto;border:1px solid gray;padding:2px;margin:0;z-index:99999;overflow:hidden;cursor:move;'+(typeof w.style.borderRadius === 'string' ? 'background-color:#eaeaea;padding-top:0px;border-radius:4px;box-shadow:0 0 15px rgba(0,0,0,.4);' : 'background:-o-skin("Window Skin");')); w.id = wId; w.closeWin = function() { doc.removeEventListener('keydown', keyDown, false); gBrowser.tabpanels.removeEventListener('mousedown', mouseDown, false); this.parentNode.removeChild(this); w = null; }; w.addEle = function(str, style) { var ele = doc.createElementNS(xhtmlns, 'div'); ele.setAttribute('style', style); if (str) { ele.innerHTML = str; for (var el, all = ele.getElementsByTagName('*'), i = all.length; i--;) { el = all[i]; if (/^(script|frame|iframe|applet|embed|object)$/i.test(el.nodeName)) { el.parentNode.removeChild(el); } else { for (var att = el.attributes, j = att.length; j--;) { if (/^on[a-z]+$/i.test(att[j].name))att[j].value = ''; } } } } return this.appendChild(ele); }; var img = doc.createElementNS(xhtmlns, 'div'); img.setAttribute('style', 'display:block;float:right;width:16px;height:16px;padding:0;margin-top:2px;margin-right:1px;border:none;cursor:pointer;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACQUlEQVR4Xm2SPUhbURTHfzfNJ4nU0Axx7CJCN2kQtIgVCtq6OdQuBUftWIQqFNsKDo6iHTqIqN3a0kklUKTS2AZrcOjioFtRjFWUfH+803cS9GHwB4dzcu75/+8L9xgaSEDbLXhaASzAyXAMn5/DHxwwjeJgKLRxd3Q0atxuLhGgWqmQmp9PJ7LZJ5Ow3WhQFweDG20LC1FfRwc3kUsm+T48fPIzl3s8VTdxxLt+/2FhdlZkc1MkmdR8Pba2ajlrz3z1+9OvIOaIfb7DwsSEyNKSyM6OSLksEo/rbw2ttadntV7Gnv3k86VfqskvmDzv7hZ580Zkelrk4kJqFIsii4satVrRs+rYmBQHBuRvS4u8g/fuCmDOz+HgAIWpKRgfh3AYhoZQ8Hqxjo4o9PdT3d1FcQEl8KoBnJ7C/j6KZkZGYG4OIhEUFed7erD29q69jGrd1qVBqcQVKgwEuMSEQhjtXRk4JvW/kM1i2WGMga4uzMoKBIOIfbNiolEC6+uU+/qQRALFA1QBlwVYxmBcLmhuxqytQSgEKu7t1dBavwKvbeINh/Has2IMqnXpem4bky6qWLdvZgaOj2FwEHNyoqG19vRMZ8jZs1+NOfsNcZS3EFvzeNL51laRe/dEYrFadsLpZeyZDx7P6QN4Btwx1OE1xO4HAquP2tsjAZ+Pm8gWi3xMpc6W8/kXPyAO/DM4oOsZa2pafdjZGXF7PAgOpXKZL4nE2XImcyUGMDSg63kbhgvgtYCq8+akIL4J3y7Fyn+DokZOnLlMyQAAAABJRU5ErkJggg==");background:-o-skin("Caption Close Button Skin");'); img.title = (win.navigator.language.indexOf('ru') == 0) ? '\u0417\u0430\u043A\u0440\u044B\u0442\u044C' : 'Close'; img.addEventListener('click', function() {this.parentNode.closeWin();}, false); w.appendChild(img); var title = w.addEle(title, 'display:table;color:#000;font:17px Times New Roman;width:auto;height:auto;padding:0;margin:0 2px;cursor:text;'); title.onclick = e => { e.preventDefault(); var url = e.target.href; // Здесь открываем url как хотим. var ctabpos = gBrowser.selectedTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addWebTab(url), ctabpos); doc.getElementById(wId).closeWin(); }; var cnt = doc.createElement("textarea"); cnt.style.cssText = ` color: #000; width: 310px; height: 160px; outline: none; padding-left: 3px; padding-bottom: 3px; border: 1px solid #aaa; background-color: #fafcfe; font: 17px Times New Roman; `; if (text) cnt.value = text; w.append(cnt); w.addEle(status, 'display:table;font:12px Times New Roman;font-weight:bold;color:blue;width:auto;height:auto;padding-top:2px;margin:0 3px;cursor:pointer;'); w.addEventListener('mousedown', function(e) { if (e.target == w) { e.preventDefault(); var grabX = e.clientX, grabY = e.clientY, origX = parseInt(w.style.left), origY = parseInt(w.style.top); var mouseMove = function(ev) { w.style.left = origX+ev.clientX-grabX+'px'; w.style.top = origY+ev.clientY-grabY+'px'; }; doc.addEventListener('mousemove', mouseMove, false); doc.addEventListener('mouseup', function() {doc.removeEventListener('mousemove', mouseMove, false);}, false); } }, false); doc.documentElement.appendChild(w); if (size) { cnt.style.height = size.height; cnt.style.width = size.width; } else { for (var i = 3; i < 10; i++) { if (cnt.scrollHeight > cnt.offsetHeight || cnt.scrollWidth > cnt.offsetWidth) { cnt.style.height = 80*i+'px'; cnt.style.width = 160*i+'px'; } else break; } } var docEle = (doc.compatMode == 'CSS1Compat' && win.postMessage) ? doc.documentElement : doc.body; var mX = docEle.clientWidth-w.offsetWidth, mY = docEle.clientHeight-w.offsetHeight; if (mX < 0) {cnt.style.width = parseInt(cnt.style.width)+mX+'px'; mX = 0;} if (mY < 0) {cnt.style.height = parseInt(cnt.style.height)+mY+'px'; mY =0;} var hW = parseInt(w.offsetWidth/2); w.style.left = (pos && pos.X < mX+hW ? (pos.X > hW ? pos.X-hW : 0) : mX)+'px'; w.style.top = (pos && pos.Y+10 < mY ? pos.Y+10 : mY)+'px'; w.style.visibility = 'visible'; doc.addEventListener('keydown', keyDown, false); gBrowser.tabpanels.addEventListener('mousedown', mouseDown, false); if (text) { var st = cnt.style; var div = cnt.editor.rootElement; var range = new Range(); range.selectNode(div.firstChild); var rect = range.getBoundingClientRect(); let w = Math.ceil(rect.width); if (cnt.scrollTopMax) { if (!matchMedia("(-moz-overlay-scrollbars)").matches) // ??? w += InspectorUtils.getChildrenForNode(div, true, false).at(-1).clientWidth; } else st.height = Math.max(50, Math.ceil(rect.height) + 2) + "px"; st.width = Math.max(200, w) + "px"; } return w; }; var getHash = function (txt) { TKK=eval('((function(){var a\x3d817046147;var b\x3d-335196159;return 410049+\x27.\x27+(a+b)})())'); function sM(a) { var b; if (null !== yr) b = yr; else { b = wr(String.fromCharCode(84)); var c = wr(String.fromCharCode(75)); b = [b(), b()]; b[1] = c(); b = (yr = window[b.join(c())] || "") || ""; } var d = wr(String.fromCharCode(116)), c = wr(String.fromCharCode(107)), d = [d(), d()]; d[1] = c(); c = "&" + d.join("") + "="; d = b.split("."); b = Number(d[0]) || 0; for (var e = [], f = 0, g = 0; g < a.length; g++) { var l = a.charCodeAt(g); 128 > l ? e[f++] = l : (2048 > l ? e[f++] = l >> 6 | 192 : (55296 == (l & 64512) && g + 1 < a.length && 56320 == (a.charCodeAt(g + 1) & 64512) ? (l = 65536 + ((l & 1023) << 10) + (a.charCodeAt(++g) & 1023), e[f++] = l >> 18 | 240, e[f++] = l >> 12 & 63 | 128) : e[f++] = l >> 12 | 224, e[f++] = l >> 6 & 63 | 128), e[f++] = l & 63 | 128); } a = b; for (f = 0; f < e.length; f++) a += e[f], a = xr(a, "+-a^+6"); a = xr(a, "+-3^+b+-f"); a ^= Number(d[1]) || 0; 0 > a && (a = (a & 2147483647) + 2147483648); a %= 1E6; return c + (a.toString() + "." + (a ^ b)); } var yr = null; var wr = function(a) { return function() { return a; }; }, xr = function(a, b) { for (var c = 0; c < b.length - 2; c += 3) { var d = b.charAt(c + 2), d = "a" <= d ? d.charCodeAt(0) - 87 : Number(d), d = "+" == b.charAt(c + 1) ? a >>> d : a << d; a = "+" == b.charAt(c) ? a + d & 4294967295 : a ^ d; } return a; }; return sM(txt); }; var ujs_google_translate = function (dir) { var lng = window.navigator.language.slice(0, 2), txt = gContextMenu.selectionInfo.fullText, l = dir.split('|'); var encTxt = encodeURIComponent(txt); var winWait = function(lng) {createWindow('', (lng == 'ru' ? 'Подождите идет перевод' : 'Wait, is going Translating')+'\u2026', 'Google Translate', '_gt', window.navigator.lastClick);}; if (txt) { winWait(lng); var xhr = new XMLHttpRequest(); var url = 'https://translate.google.com/translate_a/single?client=gtx&sl=' + l[0] + '&tl=' + l[1] + '&hl=' + lng + '&eotf=0&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t' + getHash(txt); var urlt = "http://translate.google.com/translate_t?text="+encTxt+"&sl=' + langFrom_google_text + '&tl=' + langTo_google_text +'&hl=' + lng + '&eotf=0&ujs=gtt"; xhr.open('POST', url, true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8'); xhr.onreadystatechange = function() { try { if (xhr.readyState == 4 && xhr.status == 200) { var result = '', status = '', tmp = JSON.parse(xhr.responseText.replace(/\[(?=,)/g, '[0').replace(/,(?=,|\])/g, ',0').replace(/\\n/g, ' ')); for (var i = 0, n; n = tmp[0][i]; i++) { if (n[0])result += n[0].toString(); }; status = tmp[8][0][0].toUpperCase() + ' -\u203A ' + l[1].toUpperCase(); createWindow(result, status, '<a href="'+urlt.replace(/&/g,'&')+'" target="_blank" style="display:inline;padding:0;margin:0;text-decoration:none;border:none;color:#009;font:16px Times New Roman;">Google Translate</a>', '_gt', window.navigator.lastClick); } } catch(e) {}; }; xhr.send('q=' + encodeURIComponent(txt)); } else { var urlt = gBrowser.currentURI.spec; var url = "http://translate.google.com/translate?u="+encodeURIComponent(urlt)+'&tl='+l[1]+"&hl="+lng+"&langpair="+dir+"&tbb=1"; var ctabpos = gBrowser.selectedTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addWebTab(url), ctabpos); }; }; var contextMenu = document.getElementById("contentAreaContextMenu"); var nextEleMenu = document.getElementById("context-inspect"); var menuItem = document.createXULElement("menuitem"); menuItem.setAttribute("id", "context-ru-google-translate"); menuItem.setAttribute("label", "Перевести на русский"); menuItem.setAttribute("class", "menuitem-iconic"); var image = "data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><path fill='context-fill rgb(0, 116, 232)' fill-opacity='context-fill-opacity' d='M15.37 15H17l-3.63-8.54a.75.75 0 0 0-.69-.46h-.82c-.3 0-.58.18-.7.46L9.32 10.8l-.01-.01a10.8 10.8 0 0 1-3.27-2.2 12.38 12.38 0 0 0 2.54-4.18L9.08 3H10V1.5H5.75V0h-1.5v1.5H0V3h7.5l-.33.91c-.47 1.31-1.2 2.52-2.13 3.56-.7-.9-1.25-1.9-1.63-2.97H1.8l.18.48a12.43 12.43 0 0 0 1.97 3.56c-.9.75-1.89 1.35-2.96 1.78v1.58a12.3 12.3 0 0 0 3.96-2.26 12.31 12.31 0 0 0 3.77 2.54L7.53 15h1.64l1.06-2.5h4.08l1.06 2.5Zm-4.5-4 1.4-3.3 1.4 3.3h-2.8Z'/></svg>"; var substitution = `ucf-${menuItem.id.toLowerCase()}-img`; var PHandler = Services.io.getProtocolHandler("resource") .QueryInterface(Ci.nsIResProtocolHandler); if (!PHandler.hasSubstitution(substitution)) PHandler.setSubstitution(substitution, Services.io.newURI(image)); menuItem.style.cssText = `list-style-image:url("resource://${substitution}");-moz-context-properties:fill,fill-opacity;fill:currentColor;`; menuItem.addEventListener("command", function() {ujs_google_translate('auto|ru');}, false); contextMenu.insertBefore(menuItem, nextEleMenu); contextMenu.insertBefore(document.createXULElement("menuseparator"), nextEleMenu); var translate = async () => { var br = gBrowser.selectedBrowser; var fw = Services.focus.focusedWindow; if (fw == window) { if (document.activeElement != br) return; } else if (fw.browsingContext.top != br.browsingContext) return; var cb = navigator.clipboard; var was = await cb.readText(); if (was) await cb.writeText(""); docShell.doCommand("cmd_copy"); await new Promise(r => setTimeout(r, 100)); var txt = await cb.readText(); if (txt || was) cb.writeText(was); if (!txt && !br.currentURI.scheme.startsWith("http")) return; window.gContextMenu = {selectionInfo: { get fullText() { window.gContextMenu = null; return txt; } }}; ujs_google_translate("auto|ru"); } var ts = 0, destr = this.destructor, args = ["keyup", e => e.key == "Control" && ts - (ts = Cu.now()) > -300 && !e.shiftKey && !e.altKey && translate(ts = 0) ]; addEventListener(...args); this.destructor = () => destr(removeEventListener(...args)); } }).init(this);
Отредактировано egorsemenov06 (Сегодня 22:01:00)
На форуме