// ==UserScript== // @name Twitter External Translator // @name:bg Външен преводач на Twitter // @name:zh Twitter外部翻译器 // @name:zh-CN Twitter外部翻译器 // @name:zh-TW Twitter外部翻译器 // @name:cs Externí překladatel Twitter // @name:da Twitter ekstern oversætter // @name:et Twitteri väline tõlkija // @name:fi Twitter Ulkoinen kääntäjä // @name:el Εξωτερικός μεταφραστής Twitter // @name:hu Twitter külső fordító // @name:lv Twitter Ārējais tulkotājs // @name:lt "Twitter" išorinis vertėjas // @name:ro Twitter Traducător extern // @name:sk Externý prekladateľ Twitter // @name:sl Twitter Zunanji prevajalec // @name:sv Twitter Extern översättare // @name:nl Twitter Externe Vertaler // @name:fr Traducteur externe Twitter // @name:de Externer Twitter-Übersetzer // @name:it Traduttore esterno di Twitter // @name:ja ツイッター外部翻訳者 // @name:pl Zewnętrzny tłumacz Twittera // @name:pt Tradutor externo do Twitter // @name:pt-BR Tradutor externo do Twitter // @name:ru-RU Twitter Внешний переводчик // @name:ru Twitter Внешний переводчик // @name:es Traductor externo de Twitter // @description Adds 3rd party translators to Twitter // @description:zh 将第三方翻译添加到推特 // @description:zh-CN 将第三方翻译添加到推特 // @description:zh-TW 將第三方翻譯添加到推特 // @description:bg Добавя преводачи на трети страни в Twitter // @description:cs Přidává překladatele třetích stran na Twitter // @description:da Tilføjer tredjepartsoversættere til Twitter // @description:et Lisab kolmanda osapoole tõlkijad Twitterisse // @description:fi Lisää kolmannen osapuolen kääntäjiä Twitteriin // @description:el Προσθέτει μεταφραστές 3ου μέρους στο Twitter // @description:hu Hozzáadja a 3. féltől származó fordítókat a Twitterhez // @description:lv Pievieno trešās puses tulkotājus Twitter // @description:lt Prideda trečiųjų šalių vertėjus į "Twitter // @description:ro Adaugă traducători de la terțe părți la Twitter // @description:sk Pridáva prekladateľov tretích strán na Twitter // @description:sl Dodaja prevajalce tretjih oseb na Twitterju // @description:sv Lägger till översättare från tredje part till Twitter // @description:nl Voegt vertalers van derden toe aan Twitter // @description:fr Ajout de traducteurs tiers à Twitter // @description:de Fügt Drittanbieter-Übersetzer zu Twitter hinzu // @description:it Aggiunge traduttori di terze parti a Twitter // @description:pl Dodaje tłumaczy innych firm do Twittera // @description:pt Adiciona tradutores de terceiros ao Twitter // @description:pt-BR Adiciona tradutores de terceiros ao Twitter // @description:ja サードパーティの翻訳者をツイッターに追加 // @description:ru-RU Добавляет сторонних переводчиков в Twitter // @description:ru Добавляет сторонних переводчиков в Twitter // @description:es Añade traductores de terceros a Twitter // @author Magic of Lolis // @icon https://abs.twimg.com/favicons/twitter.ico // @version 0.19 // @namespace https://github.com/magicoflolis/userscriptrepo/tree/master/ExternalTranslator#twitter-external-translator // @homepageURL https://github.com/magicoflolis/userscriptrepo/tree/master/ExternalTranslator#twitter-external-translator // @supportURL https://github.com/magicoflolis/userscriptrepo/issues/new // @require https://code.jquery.com/jquery-3.6.0.slim.min.js // @match https://www.twitlonger.com/show/* // @match https://twitter.com/* // @match https://tweetdeck.twitter.com/* // @exclude https://twitter.com/login // @exclude https://twitter.com/signup // @exclude https://twitter.com/i/flow/signup // @grant GM_getValue // @grant GM.getValue // @grant GM_setValue // @grant GM.setValue // @downloadURL none // ==/UserScript== "use strict"; //#region Config (typeof (GM) === "undefined") ? ( GM = {}, GM.setValue = GM_setValue, GM.getValue = GM_getValue ) : false; let enableLogs = false const log = (msg) => { return enableLogs ? console.log('[TET]', msg) : false; }, qs = (element) => { return document.querySelector(element); }, create = (element) => { return document.createElement(element); }, TETSetValue = (key, value) => { GM.setValue(key, value); (key === 'Config') ? (localStorage.TETConfig = value) : false; }, TETInject = (location.host == 'twitter.com') ? new MutationObserver(() => {Twitter()}).observe(document.body, {subtree:true,characterData:true,childList:true}) : (location.host == 'tweetdeck.twitter.com') ? new MutationObserver(() => {TweetDeck()}).observe(document.body, {subtree:true,characterData:true,childList:true}) : (location.host == 'www.twitlonger.com') ? new MutationObserver(() => {twitlonger()}).observe(document.body, {subtree:true,characterData:true,childList:true}) : false, isHTML = (str, doc = new DOMParser().parseFromString(str, "text/html")) => { return Array.from(doc.body.childNodes).some(node => node.nodeType === 1); }, tetCSS = `.rm, button:not(.mini) > #tetSVG, button.mini > span { display: none !important } #tetSVG { right: 35% !important } .mini { min-height: 12% !important; width: 8vw; height: auto; overflow: hidden; background: transparent } button > span { transition-property: content-visibility !important; transition-duration: 250ms !important; transition-timing-function: ease-in-out !important; transition-delay: 500ms !important; content-visibility: visible !important } button:not(.mini), #tetForm { width: -moz-available; width: -webkit-fill-available; width: 100%; width: fill-available } #tetForm { height: 100%; position: absolute } button#tetMenuButton, #tetSave, #tetReload, #tetReset { cursor: pointer; height: 5%; border-radius: 15px; justify-content: center; display: flex !important; margin-top: 3% !important; font-size: 20px !important; font-weight: bold !important; padding: 0px !important } #tetName, #tetSelector > select { padding-left: 2% } #tetSelector { margin-top: 3% !important } #tetTW { position: fixed; width: 8vw; height: 50%; overflow: hidden; top: 65%; left: 0px; z-index: 1000 !important } #tetTD { position: fixed; width: 8vw; height: 50%; overflow: hidden; top: 0; left: 90%; z-index: 1000 !important } .navbackground { z-index: 2; width: 0; height: 100%; position: fixed; top: 0; left: 0 } .r-1q3imqu { background-color: rgb(26, 145, 218); } .r-1kplyi6 { background-color: rgb(230, 156, 28); } .r-1ucxkr8 { background-color: rgb(202, 32, 85); } .r-njt2r9 { background-color: rgb(134, 93, 202); } .r-1kplyi6 { background-color: rgb(220, 84, 31); } .r-zx61xx { background-color: rgb(21, 172, 89); }`; let TETConfig = {}, LoadedConfig = {}, // Web icons are encoded in Data URI. // Can be decoded: https://www.site24x7.com/tools/datauri-to-image.html icons = { deepl: ``, yandex: ``, bing: ``, google: ``, mymemory: ``, translate: ``, }, //#region Languages en = { sel: `English (en)`, tw: `Translate with`, lg: `Language`, tr: `Translator`, ds: `Display`, ti: `Text + Icon`, rel: `Reload`, res: `Reset`, menu: `Menu`, th: `Theme`, df: `Default`, di: `Dim`, lo: `Lights out`, col: `Color`, cb: `Blue`, cy: `Yellow`, cr: `Red`, cp: `Purple`, co: `Orange`, cg: `Green`, t: `Text`, i: `Icon`, s: `Save`, fn: checkLng }, zh = { sel: `中文 (zh)`, tw: `翻译与`, lg: `语种`, tr: `译者`, ds: `显示`, ti: `文本+图标`, rel: `重新加载`, res: `复位`, menu: `菜单`, th: `主题`, df: `默认情况下`, di: `凹陷`, lo: `熄灯`, col: `颜色`, cb: `蓝色`, cy: `黄色`, cr: `红色`, cp: `紫色`, co: `橙色`, cg: `绿色`, t: `案文`, i: `图标`, s: `保存`, fn: checkLng }, bg = { sel: `Български (bg)`, tw: `Преведете с`, lg: `Език`, tr: `Преводач`, ds: `Показване на`, ti: `Текст + икона`, rel: `Презареждане`, res: `Нулиране`, menu: `Меню`, th: `Тема`, df: `По подразбиране`, di: `Dim`, lo: `Изгасяне на осветлението`, col: `Цвят`, cb: `Синьо`, cy: `Жълто`, cr: `Червено`, cp: `Лилаво`, co: `Оранжево`, cg: `Зелено`, t: `Текст`, i: `Икона`, s: `Запазване`, fn: checkLng }, cs = { sel: `Česky (cs)`, tw: `Přeložit pomocí`, lg: `Jazyk`, tr: `Překladatel`, ds: `Zobrazit`, ti: `Text + ikona`, rel: `Znovu načíst`, res: `Obnovení`, menu: `Nabídka`, th: `Téma`, df: `Výchozí`, di: `Dim`, lo: `Zhasnout světla`, col: `Barva`, cb: `Modrá`, cy: `Žlutá`, cr: `Červená`, cp: `Fialová`, co: `Oranžová`, cg: `Zelená`, t: `Text`, i: `Ikona`, s: `Uložit`, fn: checkLng }, da = { sel: `Dansk (da)`, tw: `Oversæt med`, lg: `Sprog`, tr: `Oversætter`, ds: `Vis`, ti: `Tekst + ikon`, rel: `Genindlæsning`, res: `Nulstilling`, menu: `Menu`, th: `Tema`, df: `Standard`, di: `Dim`, lo: `Lyset slukkes`, col: `Farve`, cb: `Blå`, cy: `Gul`, cr: `Rød`, cp: `Lilla`, co: `Orange`, cg: `Grøn`, t: `Tekst`, i: `Ikon`, s: `Gem`, fn: checkLng }, et = { sel: `Eesti (et)`, tw: `Tõlge koos`, lg: `Keel`, tr: `Tõlkija`, ds: `Kuva`, ti: `Tekst + ikoon`, rel: `Laadige uuesti`, res: `Reset`, menu: `Menüü`, th: `Teema`, df: `Vaikimisi`, di: `Dim`, lo: `Valgus välja lülitatud`, col: `Värv`, cb: `Sinine`, cy: `Kollane`, cr: `Punane`, cp: `Lilla`, co: `Oranž`, cg: `Roheline`, t: `Tekst`, i: `Ikoon`, s: `Salvesta`, fn: checkLng }, fi = { sel: `Suomalainen (fi)`, tw: `Käännä kanssa`, lg: `Kieli`, tr: `Kääntäjä`, ds: `Näytä`, ti: `Teksti + kuvake`, rel: `Lataa uudelleen`, res: `Reset`, menu: `Valikko`, th: `Teema`, df: `Oletus`, di: `Dim`, lo: `Valot pois päältä`, col: `Väri`, cb: `Sininen`, cy: `Keltainen`, cr: `Punainen`, cp: `Violetti`, co: `Oranssi`, cg: `Vihreä`, t: `Teksti`, i: `Kuvake`, s: `Tallenna`, fn: checkLng }, el = { sel: `Ελληνική (el)`, tw: `Μεταφράστε με`, lg: `Γλώσσα`, tr: `Μεταφραστής`, ds: `Εμφάνιση`, ti: `Κείμενο + εικονίδιο`, rel: `Επαναφόρτωση`, res: `Επαναφορά`, menu: `Μενού`, th: `Θέμα`, df: `Προεπιλογή`, di: `Dim`, lo: `Σβήνει τα φώτα`, col: `Χρώμα`, cb: `Μπλε`, cy: `Κίτρινο`, cr: `Κόκκινο`, cp: `Μωβ`, co: `Πορτοκαλί`, cg: `Πράσινο`, t: `Κείμενο`, i: `Εικονίδιο`, s: `Αποθήκευση`, fn: checkLng }, hu = { sel: `Magyar (hu)`, tw: `Fordítson a`, lg: `Nyelv`, tr: `Fordító`, ds: `Megjelenítés`, ti: `Szöveg + ikon`, rel: `Újratöltés`, res: `Reset`, menu: `Menü`, th: `Téma`, df: `Alapértelmezett`, di: `Dim`, lo: `Fények kikapcsolva`, col: `Szín`, cb: `Kék`, cy: `Sárga`, cr: `Piros`, cp: `Lila`, co: `Narancs`, cg: `Zöld`, t: `Szöveg`, i: `Ikon`, s: `Mentés`, fn: checkLng }, lv = { sel: `Latviešu (lv)`, tw: `Tulkot ar`, lg: `Valoda`, tr: `Tulkotājs`, ds: `Displejs`, ti: `Teksts + ikona`, rel: `Pārlādēt`, res: `Atiestatīt`, menu: `Izvēlne`, th: `Tēma`, df: `Noklusējuma`, di: `Dim`, lo: `Izslēgt gaismu`, col: `Krāsa`, cb: `Zils`, cy: `Dzeltens`, cr: `Sarkans`, cp: `Violeta`, co: `Oranža`, cg: `Zaļš`, t: `Teksts`, i: `Ikona`, s: `Saglabāt`, fn: checkLng }, lt = { sel: `Lietuvių kalba (lt)`, tw: `Išversti su`, lg: `Kalba`, tr: `Vertėjas`, ds: `Rodyti`, ti: `Tekstas + piktograma`, rel: `Perkrauti`, res: `Iš naujo nustatyti`, menu: `Meniu`, th: `Tema`, df: `Numatytoji`, di: `Dim`, lo: `Išjungti šviesą`, col: `Spalva`, cb: `Mėlyna`, cy: `Geltona`, cr: `Raudona`, cp: `Violetinė`, co: `Oranžinė`, cg: `Žalia`, t: `Tekstas`, i: `Ikona`, s: `Išsaugoti`, fn: checkLng }, ro = { sel: `Românesc (ro)`, tw: `Tradu cu`, lg: `Limba`, tr: `Traducător`, ds: `Afișați`, ti: `Text + Icoană`, rel: `Reîncărcare`, res: `Resetare`, menu: `Meniu`, th: `Tema`, df: `Implicit`, di: `Dim`, lo: `Stinge lumina`, col: `Culoare`, cb: `Albastru`, cy: `Galben`, cr: `Roșu`, cp: `Violet`, co: `Portocaliu`, cg: `Verde`, t: `Text`, i: `Icoană`, s: `Salvați`, fn: checkLng }, sk = { sel: `Slovenská (sk)`, tw: `Preložiť s`, lg: `Jazyk`, tr: `Prekladateľ`, ds: `Zobraziť`, ti: `Text + ikona`, rel: `Znovu načítať`, res: `Obnovenie`, menu: `Ponuka`, th: `Téma`, df: `Predvolené nastavenie`, di: `Dim`, lo: `Zhasnuté svetlá`, col: `Farba`, cb: `Modrá`, cy: `Žltá`, cr: `Červená`, cp: `Fialová`, co: `Oranžová`, cg: `Zelená`, t: `Text`, i: `Ikona`, s: `Uložiť`, fn: checkLng }, sl = { sel: `Slovenski (sl)`, tw: `Prevedi z`, lg: `Jezik`, tr: `Prevajalec`, ds: `Prikaži`, ti: `Besedilo + ikona`, rel: `Ponovno polnjenje`, res: `Ponastavitev`, menu: `Meni`, th: `Tema`, df: `Privzeto`, di: `Dim`, lo: `Ugasne luči`, col: `Barva`, cb: `Modra`, cy: `Rumena`, cr: `Rdeča`, cp: `Vijolična`, co: `Oranžna`, cg: `Zelena`, t: `Besedilo`, i: `Ikona`, s: `Shrani`, }, sv = { sel: `Svenska (sv)`, tw: `Översätt med`, lg: `Språk`, tr: `Översättare`, ds: `Visa`, ti: `Text + ikon`, rel: `Ladda om`, res: `Återställ`, menu: `Meny`, th: `Tema`, df: `Standard`, di: `Dim`, lo: `Ljuset släcks`, col: `Färg`, cb: `Blå`, cy: `Gul`, cr: `Röd`, cp: `Lila`, co: `Orange`, cg: `Grön`, t: `Text`, i: `Ikon`, s: `Spara`, fn: checkLng }, nl = { sel: `Nederlands (nl)`, tw: `Vertaal met`, lg: `Taal`, tr: `Vertaler`, ds: `Weergave`, ti: `Tekst + Pictogram`, rel: `Herladen`, res: `Reset`, menu: `Menu`, th: `Thema`, df: `Standaard`, di: `Dimmen`, lo: `Licht uit`, col: `Kleur`, cb: `Blauw`, cy: `Geel`, cr: `Rood`, cp: `Paars`, co: `Oranje`, cg: `Groen`, t: `Tekst`, i: `Icoon`, s: `Save`, fn: checkLng }, fr = { sel: `Français (fr)`, tw: `Traduire avec`, lg: `Langue`, tr: `Traducteur`, ds: `Afficher`, ti: `Texte + Icône`, rel: `Rechargez`, res: `Réinitialiser`, menu: `Menu`, th: `Thème`, df: `Défaut`, di: `Dim`, lo: `Extinction des lumières`, col: `Couleur`, cb: `Bleu`, cy: `Jaune`, cr: `Rouge`, cp: `Violet`, co: `Orange`, cg: `Vert`, t: `Texte`, i: `Icône`, s: `Sauvez`, fn: checkLng }, de = { sel: `Deutsch (de)`, tw: `Übersetzen mit`, lg: `Sprache`, tr: `Übersetzer`, ds: `Anzeige`, ti: `Text + Symbol`, rel: `Neu laden`, res: `Zurücksetzen`, menu: `Menü`, th: `Thema`, df: `Standard`, di: `Dimmen`, lo: `Licht aus`, col: `Farbe`, cb: `Blau`, cy: `Gelb`, cr: `Rot`, cp: `Lila`, co: `Orange`, cg: `Grün`, t: `Text`, i: `Icon`, s: `Speichern`, fn: checkLng }, it = { sel: `Italiano (it)`, tw: `Tradurre con`, lg: `Lingua`, tr: `Traduttore`, ds: `Visualizza`, ti: `Testo + icona`, rel: `Ricarica`, res: `Reset`, menu: `Menu`, th: `Tema`, df: `Default`, di: `Dim`, lo: `Luci spente`, col: `Colore`, cb: `Blu`, cy: `Giallo`, cr: `Rosso`, cp: `Viola`, co: `Arancione`, cg: `Verde`, t: `Testo`, i: `Icona`, s: `Salva`, fn: checkLng }, ja = { sel: `日本語 (ja)`, tw: `で翻訳する`, lg: `言語`, tr: `翻訳者`, ds: `ディスプレイ`, ti: `テキスト+アイコン`, rel: `リロード`, res: `リセット`, menu: `メニュー`, th: `テーマ`, df: `デフォルト`, di: `暗い`, lo: `消灯`, col: `カラー`, cb: `青`, cy: `黄`, cr: `赤`, cp: `紫`, co: `オレンジ`, cg: `グリーン`, t: `テキスト`, i: `アイコン`, s: `保存`, fn: checkLng }, pl = { sel: `Polski (pl)`, tw: `Tłumaczenie za pomocą`, lg: `Język`, tr: `Tłumacz`, ds: `Wyświetlacz`, ti: `Tekst + Ikona`, rel: `Przeładuj`, res: `Resetuj`, menu: `Menu`, th: `Motyw`, df: `Domyślnie`, di: `Ściemniaj`, lo: `Nie świeci się`, col: `Kolor`, cb: `Niebieski`, cy: `Żółty`, cr: `Czerwony`, cp: `Purpurowy`, co: `Pomarańczowy`, cg: `Zielony`, t: `Tekst`, i: `Ikona`, s: `Zapisz`, fn: checkLng }, pt = { sel: `Português (pt)`, tw: `Traduzir com`, lg: `Idioma`, tr: `Tradutora`, ds: `Mostrar`, ti: `Texto + Ícone`, rel: `Recarregar`, res: `Reinicialização`, menu: `Menu`, th: `Tema`, df: `Por defeito`, di: `Dim`, lo: `Luzes apagadas`, col: `Cor`, cb: `Azul`, cy: `Amarelo`, cr: `Vermelho`, cp: `Púrpura`, co: `Laranja`, cg: `Verde`, t: `Texto`, i: `Ícone`, s: `Guardar`, fn: checkLng }, ru = { sel: `Russisch (ru)`, tw: `Перевод с`, lg: `Язык`, tr: `Переводчик`, ds: `Показать`, ti: `Текст + иконка`, rel: `Перезагрузка`, res: `Перезагрузка`, menu: `Меню`, th: `Тема`, df: `По умолчанию`, di: `Приглушить`, lo: `Выключить свет`, col: `Цвет`, cb: `Синий`, cy: `Желтый`, cr: `Красный`, cp: `Фиолетовый`, co: `Оранжевый`, cg: `Зеленый`, t: `Текст`, i: `иконка`, s: `Сохранить`, fn: checkLng }, es = { sel: `Español (es)`, tw: `Traducir con`, lg: `Idioma`, tr: `Traductor`, ds: `Mostrar`, ti: `Texto + Icono`, rel: `Recarga`, res: `Reiniciar`, menu: `Menú`, th: `Tema`, df: `Por defecto`, di: `Atenuar`, lo: `Luces apagadas`, col: `Colores`, cb: `Azul`, cy: `Amarillo`, cr: `Rojo`, cp: `Púrpura`, co: `Naranja`, cg: `Verde`, t: `Texto`, i: `Icono`, s: `Guardar`, fn: checkLng }, //#endregion DefaultConfig = { theme: "#000000", colors: "r-urgr8i", cHover: "r-1q3imqu", display: 'text + icon', iconWidthA: '16', iconWidthB: '14', lang: $("html[lang]").attr("lang"), translator: 'deepl', cDisplay: `DeepL ${icons.deepl}`, cLang: en.fn().tw, cTheme: "r-kemksi", cText: "r-jwli3a", cColor: "r-p1n3y5 r-1bih22f", cSub: "r-13gxpu9", }, sidebar = `
Languages
Translators
Display
Theme
Color
`; //#endregion function checkLng() { return { tw: this.tw, lg: this.lg, tr: this.tr, ds: this.ds, ti: this.ti, rel: this.rel, res: this.res, menu: this.menu, th: this.th, df: this.df, di: this.di, lo: this.lo, col: this.col, cb: this.cb, cy: this.cy, cr: this.cr, cp: this.cp, co: this.co, cg: this.cg, t: this.t, i: this.i, s: this.s } }; function TETLanguageChange() { let TETSel = qs('select#languages').value, v = en.fn(); (TETSel == 'en') ? (v = en.fn(), TETConfig.cLang = v.tw) : (TETSel == 'bg') ? (v = bg.fn(), TETConfig.cLang = v.tw) : (TETSel == 'cs') ? (v = cs.fn(), TETConfig.cLang = v.tw) : (TETSel == 'da') ? (v = da.fn(), TETConfig.cLang = v.tw) : (TETSel == 'et') ? (v = et.fn(), TETConfig.cLang = v.tw) : (TETSel == 'fi') ? (v = fi.fn(), TETConfig.cLang = v.tw) : (TETSel == 'el') ? (v = el.fn(), TETConfig.cLang = v.tw) : (TETSel == 'hu') ? (v = hu.fn(), TETConfig.cLang = v.tw) : (TETSel == 'lv') ? (v = lv.fn(), TETConfig.cLang = v.tw) : (TETSel == 'lt') ? (v = lt.fn(), TETConfig.cLang = v.tw) : (TETSel == 'ro') ? (v = ro.fn(), TETConfig.cLang = v.tw) : (TETSel == 'sk') ? (v = sk.fn(), TETConfig.cLang = v.tw) : (TETSel == 'sl') ? (v = sl.fn(), TETConfig.cLang = v.tw) : (TETSel == 'sv') ? (v = sv.fn(), TETConfig.cLang = v.tw) : (TETSel == 'zh') ? (v = zh.fn(), TETConfig.cLang = v.tw) : (TETSel == 'nl') ? (v = nl.fn(), TETConfig.cLang = v.tw) : (TETSel == 'fr') ? (v = fr.fn(), TETConfig.cLang = v.tw) : (TETSel == 'de') ? (v = de.fn(), TETConfig.cLang = v.tw) : (TETSel == 'it') ? (v = it.fn(), TETConfig.cLang = v.tw) : (TETSel == 'ja') ? (v = ja.fn(), TETConfig.cLang = v.tw) : (TETSel == 'pl') ? (v = pl.fn(), TETConfig.cLang = v.tw) : (TETSel == 'pt') ? (v = pt.fn(), TETConfig.cLang = v.tw) : (TETSel == 'ru') ? (v = ru.fn(), TETConfig.cLang = v.tw) : (TETSel == 'es') ? (v = es.fn(), TETConfig.cLang = v.tw) : (v = en.fn(), TETConfig.cLang = v.tw); $('button#tetMenuButton').attr('title', v.menu) $('button#tetMenuButton > span').text(v.menu) $('select#languages').siblings().children("span").text(v.lg) $('select#translator').siblings().children("span").text(v.tr) $('select#display').siblings().children("span").text(v.ds) $('select#theme').siblings().children("span").text(v.th) $('option[value="#FFFFFF"]').text(v.df) $('option[value="#15202B"]').text(v.di) $('option[value="#000000"]').text(v.lo) $('select#colorselect').siblings().children("span").text(v.col) $('option[value="r-urgr8i"]').text(v.cb) $('option[value="r-1vkxrha"]').text(v.cy) $('option[value="r-1dgebii"]').text(v.cr) $('option[value="r-1qqlz1x"]').text(v.cp) $('option[value="r-18z3xeu"]').text(v.co) $('option[value="r-b5skir"]').text(v.cg) $('option[value="text + icon"]').text(v.ti) $('option[value="text"]').text(v.t) $('option[value="icon"]').text(v.i) $('button#tetSave').text(v.s) $('button#tetReload').text(v.rel) $('button#tetReset').text(v.res) TETDisplayChange() } function TETDisplayChange(mode = "nonrepeat") { let cSel = qs('select#translator').value, disA = (cSel == "bing") ? (TETConfig.cDisplay = `Bing`) : (cSel == "google") ? (TETConfig.cDisplay = `Google`) : (cSel == "mymemory") ? (TETConfig.cDisplay = `MyMemory`) : (cSel == "translate") ? (TETConfig.cDisplay = `Translate.com`) : (cSel == "yandex") ? (TETConfig.cDisplay = `Yandex`) : (TETConfig.cDisplay = `DeepL`), disB = (cSel == "bing") ? (TETConfig.cDisplay = icons.bing) : (cSel == "mymemory") ? (TETConfig.cDisplay = icons.mymemory) : (cSel == "translate") ? (TETConfig.cDisplay = icons.translate) : (cSel == "yandex") ? (TETConfig.cDisplay = icons.yandex) : (TETConfig.cDisplay = icons.deepl), disC = (cSel == "bing") ? (TETConfig.cDisplay = `Bing ${icons.bing}`) : (cSel == "google") ? (TETConfig.cDisplay = `Google ${icons.google}`) : (cSel == "mymemory") ? (TETConfig.cDisplay = `MyMemory ${icons.mymemory}`) : (cSel == "translate") ? (TETConfig.cDisplay = `Translate.com ${icons.translate}`) : (cSel == "yandex") ? (TETConfig.cDisplay = `Yandex ${icons.yandex}`) : (TETConfig.cDisplay = `DeepL ${icons.deepl}`), checkDisplay = (qs('select#display').value == 'text') ? disA : (qs('select#display').value == 'icon') ? disB : disC; return (mode == "repeat") ? checkDisplay : ( $('.tet').html(`${TETConfig.cLang} ${TETConfig.cDisplay}`), $('.tet').hover( function() { $(this).toggleClass("r-1ny4l3l r-1ddef8g") }, function() { $(this).toggleClass("r-1ny4l3l r-1ddef8g") }) ) } async function Twitter() { let content = '',magicBtn,btContainer,btLang,site, translateTweet = $("div[lang]").eq(0).siblings().eq(0).children("span"), // "Translate Tweet" button translateBio = $('div[data-testid="UserDescription"]').eq(0).siblings().eq(0).children("span"), // "Translate Bio" button trTweet = $("div[lang]").eq(0).siblings().eq(1), // [Tweet] "Translate with ..." button trBio = $('div[data-testid="UserDescription"]').eq(0).siblings().eq(1), // [Bio] "Translate with ..." button tweetbtn = () => { log("Injecting tweet button") btContainer = translateTweet.parent().siblings().eq(0), // "Tweet" btLang = btContainer.attr("lang"); magicBtn = translateTweet.parent().clone().appendTo(translateTweet.parent().parent()); btContainer.children("span").each((index,item) => { let tweet = $(item).html().trim(); (tweet && tweet != '' && !isHTML(tweet)) ? content += ` ${tweet}` : false; }); (!btLang) ? (btLang = "auto") : false; magicBtn.addClass("tet") TETDisplayChange() site = (TETConfig.translator == 'yandex') ? `https://translate.yandex.com/?lang=${btLang}-${TETConfig.lang}&text=${content}` : (TETConfig.translator == 'bing') ? `https://www.bing.com/translator/?text=${content}&from=${btLang}&to=${TETConfig.lang}` : (TETConfig.translator == 'google') ? `https://translate.google.com/?q=${content}&sl=${btLang}&tl=${TETConfig.lang}` : (TETConfig.translator == 'mymemory') ? `https://mymemory.translated.net/${TETConfig.lang}/${btLang}/${TETConfig.lang}/${content}` : (TETConfig.translator == 'translate') ? `https://www.translate.com/#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", () => { window.open(`${site}`,'_blank'); }) }, biobtn = () => { log("Injecting bio button") btContainer = translateBio.parent().siblings().eq(0); // "User Bio" btLang = $("div[lang]").attr("lang"); magicBtn = translateBio.parent().clone().appendTo(translateBio.parent().parent()); btContainer.children("span").each((index,item) => { let bio = $(item).html().trim(); (bio && bio != '' && !isHTML(bio)) ? content += ` ${bio}` : false; }); (!btLang) ? (btLang = "auto") : false; magicBtn.addClass("tet") TETDisplayChange() site = (TETConfig.translator == 'yandex') ? `https://translate.yandex.com/?lang=${btLang}-${TETConfig.lang}&text=${content}` : (TETConfig.translator == 'bing') ? `https://www.bing.com/translator/?text=${content}&from=${btLang}&to=${TETConfig.lang}` : (TETConfig.translator == 'google') ? `https://translate.google.com/?q=${content}&sl=${btLang}&tl=${TETConfig.lang}` : (TETConfig.translator == 'mymemory') ? `https://mymemory.translated.net/${TETConfig.lang}/${btLang}/${TETConfig.lang}/${content}` : (TETConfig.translator == 'translate') ? `https://www.translate.com/#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", () => { window.open(`${site}`,'_blank'); }) }; ($('.exIcon').length) ? $('.exIcon').attr('width', TETConfig.iconWidthA) : false; return (!trBio.length && translateBio.length) ? biobtn() : (!trTweet.length && translateTweet.length) ? tweetbtn() : TETDisplayChange("repeat"); } async function TweetDeck() { let content = '',magicBtn,btContainer,btLang,site, translateTweet = $('a.js-translate-call-to-action'), // "Translate Tweet" button trTweet = translateTweet.eq(1), // [Tweet] "Translate with ..." button trBio = $("#tet"), tweetbtn = () => { log("Injecting tweet button") btContainer = translateTweet.siblings().eq(2), // "Tweet" content = btContainer.text(), // Content of "Tweet" btLang = btContainer.attr("lang"); magicBtn = translateTweet.before(translateTweet.clone()); // Create external translation button (!btLang) ? (btLang = "auto") : false; magicBtn.addClass("tet") TETDisplayChange() site = (TETConfig.translator == 'yandex') ? `https://translate.yandex.com/?lang=${btLang}-${TETConfig.lang}&text=${content}` : (TETConfig.translator == 'bing') ? `https://www.bing.com/translator/?text=${content}&from=${btLang}&to=${TETConfig.lang}` : (TETConfig.translator == 'google') ? `https://translate.google.com/?q=${content}&sl=${btLang}&tl=${TETConfig.lang}` : (TETConfig.translator == 'mymemory') ? `https://mymemory.translated.net/${TETConfig.lang}/${btLang}/${TETConfig.lang}/${content}` : (TETConfig.translator == 'translate') ? `https://www.translate.com/#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", () => { window.open(`${site}`,'_blank'); }) }, biobtn = () => { log("Injecting bio button") btContainer = $('p.prf-bio') content = btContainer.text() // Content of "Tweet" magicBtn = $('').appendTo(btContainer.parent()) // Create external translation button btLang = "auto" TETDisplayChange() site = (TETConfig.translator == 'yandex') ? `https://translate.yandex.com/?lang=${btLang}-${TETConfig.lang}&text=${content}` : (TETConfig.translator == 'bing') ? `https://www.bing.com/translator/?text=${content}&from=${btLang}&to=${TETConfig.lang}` : (TETConfig.translator == 'google') ? `https://translate.google.com/?q=${content}&sl=${btLang}&tl=${TETConfig.lang}` : (TETConfig.translator == 'mymemory') ? `https://mymemory.translated.net/${TETConfig.lang}/${btLang}/${TETConfig.lang}/${content}` : (TETConfig.translator == 'translate') ? `https://www.translate.com/#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", () => { window.open(`${site}`,'_blank'); }) }, check = () => { (!trBio.length && $('div.prf-header').length) ? biobtn() : false; (!trTweet.length && translateTweet.length) ? tweetbtn() : trTweet.attr('style', 'display: flex !important; align-items: end !important;') TETDisplayChange("repeat") }; ($('.exIcon').length) ? $('.exIcon').attr('width', TETConfig.iconWidthA) : false; return check() } async function twitlonger() { let content = $('p#posttext').text(),magicBtn,btLang,site, trBio = $("#tet"), tweetbtn = () => { log("Injecting tweet button") magicBtn = $('').appendTo($('p.actions.text-right')) // Create external translation button btLang = "auto" TETDisplayChange() site = (TETConfig.translator == 'yandex') ? `https://translate.yandex.com/?lang=${btLang}-${TETConfig.lang}&text=${content}` : (TETConfig.translator == 'bing') ? `https://www.bing.com/translator/?text=${content}&from=${btLang}&to=${TETConfig.lang}` : (TETConfig.translator == 'google') ? `https://translate.google.com/?q=${content}&sl=${btLang}&tl=${TETConfig.lang}` : (TETConfig.translator == 'mymemory') ? `https://mymemory.translated.net/${TETConfig.lang}/${btLang}/${TETConfig.lang}/${content}` : (TETConfig.translator == 'translate') ? `https://www.translate.com/#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", () => { window.open(`${site}`,'_blank'); }) }; ($('.exIcon').length) ? $('.exIcon').attr('width', TETConfig.iconWidthA) : false; return (!trBio.length && $('p.actions.text-right').length) ? tweetbtn() : TETDisplayChange("repeat"); } function injectMenu() { try { log("Injecting Menu") let body = $("body"), nav = create("div"); nav.className = "navbackground"; body.before(nav, sidebar); qs('select#theme').value = TETConfig.theme; qs('select#colorselect').value = TETConfig.colors; qs('select#languages').value = TETConfig.lang; qs('select#translator').value = TETConfig.translator; qs('select#display').value = TETConfig.display; (location.host == 'www.twitlonger.com') ? ($("div#tetSelector").eq(3).addClass('rm'),$("div#tetSelector").eq(4).addClass('rm') ) : false; (location.host == 'tweetdeck.twitter.com') ? ( $('div.btNav').attr("id", "tetTD"), $('button.tetBtn').each(function () { $(this).addClass("Button--primary") }), $("div#tetSelector").eq(3).addClass('rm'), $("div#tetSelector").eq(4).addClass('rm') ) : false; $(".tetBackground").each(function () { $(this).addClass(TETConfig.cTheme) $(this).removeClass("tetBackground") }) $(".tetTextColor").each(function () { $(this).addClass(TETConfig.cText) $(this).removeClass("tetTextColor") }) $(".tetDisplayColor").each(function () { $(this).addClass(TETConfig.colors) $(this).removeClass("tetDisplayColor") }) nav.onclick = async () => { $('.btNav > form').toggleClass("rm"); $('button#tetMenuButton').attr("style", ""); $('svg#tetSVG').show(); $('button#tetMenuButton').addClass("mini"); nav.style.width = "0%"; setTimeout(() => $('svg#tetSVG').hide(), 5000); }; $('button#tetMenuButton').hover(function() { $('svg#tetSVG').hide() $(this).toggleClass("mini"); }, function() { $('svg#tetSVG').show() $(this).toggleClass("mini"); setTimeout(() => $('svg#tetSVG').hide(), 5000); }); qs('button#tetMenuButton').onclick = async () => { nav.style.width = "100%"; $('.btNav > form').toggleClass("rm"); $('button#tetMenuButton').attr("style", "display: none !important;"); } $('div#tetSelector').hover(function() { $(this).toggleClass(`${TETConfig.cColor} r-1kqtdi0`) $(this).children("div#tetName").toggleClass(`${TETConfig.cSub} r-9ilb82`) }, function() { $(this).toggleClass(`${TETConfig.cColor} r-1kqtdi0`) $(this).children("div#tetName").toggleClass(`${TETConfig.cSub} r-9ilb82`) }); qs('select#theme').onchange = () => { let cSel = qs('select#theme').value; (cSel == "#FFFFFF") ? (TETConfig.cTheme = "r-14lw9ot", TETConfig.cText = "r-18jsvk2") : (cSel == "#15202B") ? (TETConfig.cTheme = "r-yfoy6g", TETConfig.cText = "r-jwli3a") : (cSel == "#000000") ? (TETConfig.cTheme = "r-kemksi", TETConfig.cText = "r-jwli3a") : (TETConfig.theme = "#000000", TETConfig.cTheme = "r-kemksi", TETConfig.cText = "r-jwli3a"); TETConfig.theme = cSel } qs('select#colorselect').onchange = () => { let cSel = qs('select#colorselect').value; (cSel == "r-urgr8i") ? (TETConfig.colors = "r-urgr8i",TETConfig.cHover = "r-1q3imqu",TETConfig.cColor = "r-p1n3y5 r-1bih22f",TETConfig.cSub = "r-13gxpu9") : (cSel == "r-1vkxrha") ? (TETConfig.colors = "r-1vkxrha",TETConfig.cHover = "r-1kplyi6",TETConfig.cColor = "r-v6khid r-cdj8wb",TETConfig.cSub = "r-61mi1v") : (cSel == "r-1dgebii") ? (TETConfig.colors = "r-1dgebii",TETConfig.cHover = "r-1ucxkr8",TETConfig.cColor = "r-1iofnty r-jd07pc",TETConfig.cSub = "r-daml9f") : (cSel == "r-1qqlz1x") ? (TETConfig.colors = "r-1qqlz1x",TETConfig.cHover = "r-njt2r9",TETConfig.cColor = "r-hy56xe r-11mmphe",TETConfig.cSub = "r-xfsgu1") : (cSel == "r-18z3xeu") ? (TETConfig.colors = "r-18z3xeu",TETConfig.cHover = "r-1kplyi6",TETConfig.cColor = "r-1xl5njo r-b8m25f",TETConfig.cSub = "r-1qkqhnw") : (cSel == "r-b5skir") ? (TETConfig.colors = "r-b5skir",TETConfig.cHover = "r-zx61xx",TETConfig.cColor = "r-5ctkeg r-1cqwhho",TETConfig.cSub = "r-nw8l94") : (TETConfig.colors = "r-urgr8i",TETConfig.cHover = "r-1q3imqu",TETConfig.cColor = "r-p1n3y5 r-1bih22f",TETConfig.cSub = "r-13gxpu9"); TETConfig.colors = cSel; } qs('select#languages').onchange = () => { TETLanguageChange(); TETConfig.lang = qs('select#languages').value; } qs('select#translator').onchange = () => { TETConfig.translator = qs('select#translator').value; TETDisplayChange(); } qs('select#display').onchange = () => { TETConfig.display = qs('select#display').value; TETDisplayChange(); } qs('button#tetSave').onclick = async () => { TETSetValue("Config", JSON.stringify(TETConfig)) setTimeout(() => window.location.reload(), 200) } qs('button#tetReload').onclick = async () => { TETInject; } qs('button#tetReset').onclick = async () => { TETConfig = DefaultConfig; TETSetValue("Config", JSON.stringify(TETConfig)) setTimeout(() => window.location.reload(), 200) } setTimeout(() => $('svg#tetSVG').hide(), 5000); } catch (e) { TETConfig = DefaultConfig; (!enableLogs) ? (enableLogs = true) : false; log(e) } } Promise.all([GM.getValue("Config")]).then((data) => { let res = data[0] if (res != null) { try { TETConfig = JSON.parse(res); } catch (e) { TETConfig = res; } } else { TETConfig = DefaultConfig; } const localData = localStorage.TETConfig; (localData && localData.length > 0) ? TETConfig = JSON.parse(localData) : false; for (let key in DefaultConfig) { (typeof (TETConfig[key])) ?? (TETConfig[key] = DefaultConfig[key]); } LoadedConfig = JSON.parse(JSON.stringify(TETConfig)); document.head.insertAdjacentHTML('beforeend', ``); log(LoadedConfig) injectMenu(); (TETConfig.lang != "en" || TETConfig.lang != "en-US") ? TETLanguageChange() : false; TETInject log("Config Loaded") }).catch((e) => { (!enableLogs) ? (enableLogs = true) : false; log(e) TETConfig = DefaultConfig; }); //#endregion