- Firefox-Version
- 128.0.2
- Betriebssystem
- Win 10
Ich habe zwei Skripte im Kontextmenü für Übersetzungen (DeepL und Google). Das Skript für Google funktioniert nicht mehr, man landet immer auf der Hauptseite von google Translate ohne dass das Wort, welches man markiert hat und mittels Kontextmenü übersetzen möchte, erscheint.
Mein momentaner Code für gTranslate:
JavaScript
// ContextTranslate.uc.js
(function () {
if (location != 'chrome://browser/content/browser.xhtml')
return;
let translate = function () {
let browserMM = gBrowser.selectedBrowser.messageManager;
browserMM.addMessageListener('getSelection', function listener(message) {
let t = (message.data !== '');
let e = (document.charset || document.characterSet);
if (t) {
openWebLinkIn('https://translate.google.com/#view=home&op=translate&sl=auto&tl=de&text=' + encodeURIComponent(message.data), 'tab');
} else {
openWebLinkIn('https://translate.google.com/translate?u=' + encodeURIComponent(gBrowser.currentURI.spec) + '&hl=de-DE&ie=' + e + '&sl=auto&tl=de-DE', 'tab');
};
browserMM.removeMessageListener('getSelection', listener, true);
});
browserMM.loadFrameScript('data:,sendAsyncMessage("getSelection", content.document.getSelection().toString())', true);
}
let menuitem = document.createXULElement('menuitem');
menuitem.id = 'context-googletranslate';
menuitem.setAttribute('label', 'gTranslate->de');
menuitem.setAttribute('tooltiptext', 'Mit GoogleTranslate übersetzen');
menuitem.setAttribute('oncommand', '(' + translate.toString() + ')()');
menuitem.classList.add('menuitem-iconic');
//Wer kein Icon möchte kann die nächsten beiden Zeilen auskommentieren/löschen
//menuitem.style.listStyleImage = 'url("https://translate.google.com/favicon.ico")';
menuitem.style.listStyleImage = ' url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAwCAYAAABT9ym6AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAHYklEQVRoQ+2Y6U+UVxSH9Xs/NGnSv6et1h1REWOrUEaomiZt2tQqRQFFcNiRImg1rnVB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Iy6mBxiYHXktc4HK1ss8mdKUnAYFeRMjwx0eu0rJrU1djcA0ocTS7BhoabWC10kjRV6nKlxEUXi2jFlF3hT8+cpWc/OST1bEPUUBhVUwVpKNEY5MdXrxwMglPaxu0tyvdEOhF9OPFHx/ZSvjh8SSNEkmkqTpht+Pndg+NFHXDy9CL6LtCIti5Mf7oyFZK5rNU0QlLw0toaaHvgHEv3B4cqTYUoY4oMmoR8aoXefS4ycQfHdmi8UozP4Ha2mawWFpQ5CW+Z9BuOHHJ6dsUHC8PSbUaUEvi7/uqHjXswUeuVJ78od7HWrHiXwQB769LvTEjAAAAAElFTkSuQmCC")';
let refItem = document.getElementById('context-inspect');
refItem.parentNode.insertBefore(menuitem, refItem);
})();
Alles anzeigen
Der andere Code von DeepL funktioniert hingegen problemlos
JavaScript
//// Translate DeepL ////
///https://github.com/ardiman/userChrome.js/tree/master/contexttranslate///
// ContextTranslateDeepL.uc.js
(function () {
if (location != 'chrome://browser/content/browser.xhtml')
return;
let translate = function () {
let browserMM = gBrowser.selectedBrowser.messageManager;
browserMM.addMessageListener('getSelection', function listener(message) {
let t = (message.data !== '');
let e = (document.charset || document.characterSet);
if (t) {
openWebLinkIn('https://www.deepl.com/translator#en/de/' + encodeURIComponent(message.data), 'tab');
} else {
openWebLinkIn('https://www.deepl.com/translate?u=' + encodeURIComponent(gBrowser.currentURI.spec) + '&hl=de-DE&ie=' + e + '&sl=auto&tl=de-DE', 'tab');
};
browserMM.removeMessageListener('getSelection', listener, true);
});
browserMM.loadFrameScript('data:,sendAsyncMessage("getSelection", content.document.getSelection().toString())', true);
}
let menuitem = document.createXULElement('menuitem');
menuitem.id = 'context-googletranslate';
menuitem.setAttribute('label', 'Deepl->de');
menuitem.setAttribute('tooltiptext', 'Mit DeeplTranslate übersetzen');
menuitem.setAttribute('oncommand', '(' + translate.toString() + ')()');
menuitem.classList.add('menuitem-iconic');
//Wer kein Icon möchte kann die nächsten beiden Zeilen auskommentieren/löschen
//menuitem.style.listStyleImage = 'url("https://www.deepl.com/favicon.ico")';
menuitem.style.listStyleImage = ' url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAACNwAAAjcB9wZEwgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAGZSURBVDiNjZKxaxRBFMZ/b2ZHbWITUxkRC4PnBUW0k1gkoFlMYmIR8R+w0UZBFAvtLAMS0ipC0guCd0GOa23EJGTPkBRCSCNHKiEgMzvPwmjCuiv3lft97zff7BuhQraWTouJLwE0mmf518a7spwUPxwZvlmLms8B4wWrLZhHPvuwUg44N9afGPcc4T5gK4pFgSUv/jHrre8HgKHJE4nzHWBgn/sZdBuYqQB1Q+5rbLR2DUBy1J89GIbEmNmQNW8DqxWAgcS5IQBT5vqYP3H1Gw9AHyosAKECVA4QuKfIPMhHVKygV4OVU8ByT4BDsiI6rWpusdbYUdgpBpLSMeGTRLYx2o5q9kT0ja2P3xU401ODQJz1neYdVRkT9C1gyob/Ngg/3VbifJf9TVg1L2Q43UC1eo3eb8KfB7O7uRf7T782Yo8hXBG4DFwvaRgFFoP4GTqt7u/bFuTOp5dU9BUw8u/BOhqy5fZ//4HvNL6ErHlNkSmFb4e9YM1WMV+5xjxrvM+P99VBngI/qnK96UI66OrpEhcnThatXx/tiqJJdDA6AAAAAElFTkSuQmCC';
let refItem = document.getElementById('context-inspect');
refItem.parentNode.insertBefore(menuitem, refItem);
})();
Alles anzeigen
kann mir jemand sagen was ich im oberen Code ändern muss damit dieser auch wieder funktioniert?