// ==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 external & internal translators // @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.27 // @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://twitter.com/* // @match https://tweetdeck.twitter.com/* // @match https://www.twitlonger.com/show/* // @match https://nitter.net/* // @match https://nitter.*/* // @match https://nitter.*.*/* // @match https://nitter.domain.glass/* // @match https://nitter-home.kavin.rocks/* // @match https://birdsite.xanny.family/* // @match https://twitr.gq/* // @exclude https://twitter.com/login // @exclude https://twitter.com/signup // @exclude https://twitter.com/i/flow/signup // @exclude https://twitter.com/teams/* // @exclude https://twitter.com/*/authorize?* // @exclude https://twitter.com/*/begin_password_reset // @grant GM_getValue // @grant GM.getValue // @grant GM_setValue // @grant GM.setValue // @grant GM_info // @grant GM_xmlhttpRequest // @downloadURL none // ==/UserScript== "use strict"; (async () => { //#region Config (typeof (GM) === "undefined") ? (GM = {},GM.setValue = GM_setValue,GM.getValue = GM_getValue) : false; let enableLogs = false, tetInfo = { name: GM_info.script.name, version: GM_info.script.version }; // Enables logs during development. (tetInfo.name === "[Dev] Twitter External Translator") ? enableLogs = true : false; const log = (msg) => { return enableLogs ? console.log('[TET]', msg) : false; }, qs = (element) => { return document.querySelector(element); }, injectCSS = (css) => { return document.head.insertAdjacentHTML('beforeend', ``); }, autoHide = async () => { await new Promise((resolve) => setTimeout(resolve, 5000)); $('svg#tetSVG').hide(); }, TETSetValue = (key, value) => { GM.setValue(key, value); (key === 'Config') ? (localStorage.TETConfig = value) : false; }, LH = document.location.host, TETInject = (LH == 'twitter.com') ? new MutationObserver(() => {Twitter()}).observe(document.body, {subtree:true,childList:true}) : (LH == 'tweetdeck.twitter.com') ? new MutationObserver(() => {TweetDeck()}).observe(document.body, {subtree:true,childList:true}) : (LH == 'www.twitlonger.com') ? document.addEventListener('DOMContentLoaded', TwitLonger()) : (/nitter/.test(window.location.href) || LH == 'twitr.gq' || LH == 'birdsite.xanny.family') ? new MutationObserver(() => {Nitter()}).observe(document.body, {subtree:true,childList:true}) : false, isHTML = (str, doc = new DOMParser().parseFromString(str, "text/html")) => { return Array.from(doc.body.childNodes).some(node => node.nodeType === 1); }, icons = { azure: '', bing: '', deepl: '', gCloud: '', google: '', mymemory: '', translate: '', yandex: '', fn() { return { azure: this.azure, bing: this.bing, deepl: this.deepl, gCloud: this.gCloud, google: this.google, mymemory: this.mymemory, translate: this.translate, yandex: this.yandex, } } }, twCSS = `.css-1dbjc4n{-ms-flex-align:stretch;-ms-flex-direction:column;-ms-flex-negative:0;-ms-flex-preferred-size:auto;-webkit-align-items:stretch;-webkit-box-align:stretch;-webkit-box-direction:normal;-webkit-box-orient:vertical;-webkit-flex-basis:auto;-webkit-flex-direction:column;-webkit-flex-shrink:0;align-items:stretch;border:0 solid #000;box-sizing:border-box;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;flex-basis:auto;flex-direction:column;flex-shrink:0;margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;min-height:0px;min-width:0px;position:relative;z-index:0}select{height:auto !important}.r-qvutc0{overflow-wrap:break-word}.r-1adg3ll{display:block}.r-u8s1d{position:absolute}.r-1wbh5a2{flex-shrink:1}.r-1ny4l3l{outline-style:none}.r-sdzlij{border-radius:9999px}.r-z2wwpe{border-radius:4px !important}.r-rs99b7{border-width:1px}.r-1moyyf3{border-bottom-right-radius:16px}.r-1pp923h{border-bottom-left-radius:16px}.r-1mi75qu{box-shadow:rgba(0,0,0,.02) 0px 0px 2px inset}.r-1mlwlqe{flex-basis:auto}.r-1udh08x{overflow:hidden}.r-1awozwy{-webkit-box-align:center;-moz-box-align:center;align-items:center}.r-1hwvwag{flex-basis:48px}.r-18kxxzh{-webkit-box-flex:0;flex-grow:0}.r-1777fci{-webkit-box-pack:center;-moz-box-pack:center;justify-content:center}.r-1pi2tsx{height:100%}.r-18u37iz{-webkit-box-direction:normal;-webkit-box-orient:horizontal;-moz-box-direction:normal;-moz-box-orient:horizontal;flex-direction:row}.r-ipm5af{top:0px}.r-1ifxtd0{margin-bottom:16px}.r-6gpygo{margin-bottom:12px !important}.r-1jgb5lz{margin-left:auto;margin-right:auto}.r-1ye8kvj{max-width:600px}.r-16y2uox{-webkit-box-flex:1;-moz-box-flex:1;flex-grow:1}.r-ttdzmv{padding-top:12px !important}.r-1iusvr4{flex-basis:0px}.r-13qz1uu{width:100%}.r-1dye5f7{padding-left:32px;padding-right:32px}.r-9ilb82{color:#6e767d}.r-16dba41{font-weight:400}.r-1vr29t4{font-weight:800}.r-a023e6{font-size:15px}.r-1qd0xha{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}.r-rjixqe{line-height:20px}.r-1cwl3u0{line-height:16px}.r-bcqeeo{min-width:0px}.r-q4m81j{text-align:center}.r-zchlnj{right:0px}.r-1d2f490{left:0px}.r-1p0dtai{bottom:0px}.r-13awgt0{-ms-flex:1 1 0%;-webkit-flex:1;flex:1}.r-1b2b6em{line-height:2em}.r-q4m81j{text-align:center}/*# sourceMappingURL=foreign.css.map */`, tetCSS = `.tetNitterHover{background-color:#1a1a1a}.tetNitter{background-color:transparent}.tetNText{text-decoration:underline}.r-urgr8i{background-color:#1da1f2}.r-p1n3y5{border-color:#1da1f2}.r-13gxpu9{color:#1da1f2}.r-1q3imqu{background-color:#1a91da}.r-1bih22f{box-shadow:#1da1f2 0px 0px 0px 1px}.r-1vkxrha{background-color:#ffad1f}.r-v6khid{border-color:#ffad1f}.r-61mi1v{color:#ffad1f}.r-1kplyi6{background-color:#e69c1c}.r-cdj8wb{box-shadow:#ffad1f 0px 0px 0px 1px}.r-1dgebii{background-color:#e0245e}.r-1iofnty{border-color:#e0245e}.r-daml9f{color:#e0245e}.r-1ucxkr8{background-color:#ca2055}.r-jd07pc{box-shadow:#e0245e 0px 0px 0px 1px}.r-1qqlz1x{background-color:#794bc4}.r-njt2r9{background-color:#865dca}.r-hy56xe{border-color:#794bc4}.r-11mmphe{box-shadow:#794bc4 0px 0px 0px 1px}.r-xfsgu1{color:#794bc4}.r-18z3xeu{background-color:#f45d22}.r-1kplyi6{background-color:#dc541f}.r-1xl5njo{border-color:#f45d22}.r-b8m25f{box-shadow:#f45d22 0px 0px 0px 1px}.r-1qkqhnw{color:#f45d22}.r-b5skir{background-color:#17bf63}.r-zx61xx{background-color:#15ac59}.r-5ctkeg{border-color:#17bf63}.r-1cqwhho{box-shadow:#17bf63 0px 0px 0px 1px}.r-nw8l94{color:#17bf63}.r-yfoy6g{background-color:#15202b}.r-14lw9ot{background-color:#fff}.r-kemksi{background-color:#000}.r-18jsvk2{color:#0f1419}.Button--primary{background-color:#1da1f2 !important;border:1px solid #1da1f2 !important;color:#fff !important}.r-demo{border-style:solid !important;border-radius:16px !important;border-width:1px !important}.demo-TW{border-color:#2f3336 !important}.demo-TD{border:1px solid #000 !important}.demo-NT{border:1px solid var(--accent_border) !important}html.dark .r-tetTD{background-color:#15202b !important;border-radius:14px}.r-tetTD{background-color:#fff !important;border-radius:14px}.r-hoverTD{background-color:#005fd1;border-color:#005fd1;color:#fff}.r-jwli3a{color:#fff}.tet{margin-top:4px;flex-wrap:wrap;line-height:16px;font-size:13px;font-weight:400;overflow-wrap:break-word;min-width:0px;display:flex}.r-kzbkwu{padding-bottom:12px !important}.r-i023vh{padding-right:16px !important}.r-1qhn6m8{padding-left:16px !important}.r-11rk87y{padding-bottom:32px !important}.r-1v1z2uz{margin-top:32px !important}.r-1n7yuxj{margin-left:32px !important;margin-right:32px !important}.r-vrz42v{line-height:28px}.r-1blvdjr{font-size:23px}.r-htvplk{min-width:600px !important}.r-rsyp9y{max-height:90vh}.r-1pjcn9w{max-width:80vw}.rm,button:not(.mini)>#tetSVG,button.mini>span{display:none !important}.tetFreeze{overflow:hidden !important;overscroll-behavior-y:none !important}#tetMenuButton,#tetSave,#tetReload,#tetReset{list-style:none;text-align:inherit;text-decoration:none;border-radius:15px;justify-content:center;display:flex !important;font-family:inherit;font-size:20px !important;font-weight:bold !important;padding:0px !important}#tetMenuButton{z-index:10;width:8vw;height:auto;position:fixed;top:65%;left:0px}#tetMenuButton.tetTD{left:90% !important;top:0% !important}#tetMenuButton,#tetSave,#tetReload,#tetReset,#tet,.tet{cursor:pointer !important}input#apifield,#tetName,#tetSelector>select{padding-left:2% !important}#tetSave,#tetReload,#tetReset{margin:2% 25% 0px 25%;}#apifield,#tetSelector{margin-top:2%}#tetDemo{margin:4px 0px 4px 0px;line-height:16px;font-size:13px;flex-wrap:wrap;font-weight:400;min-width:0px;display:flex !important}.btNav,.navbackground{position:fixed !important;width:100vw;height:100vh}#tetSVG{right:35% !important}.navbackground{top:0;left:0}.mini{min-height:3% !important;overflow:hidden;background:transparent}.r-hover{text-decoration-line:underline !important;outline-style:none !important}/*# sourceMappingURL=menu.css.map */`; let TETConfig = {}, //#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 = { api: { deepl: '', google: '', version: "api-free", }, cBG: 'rgba(91, 112, 131, 0.4)', cColor: "r-p1n3y5 r-1bih22f", cDisplay: `DeepL ${icons.deepl}`, cHover: "r-1q3imqu", cLang: en.fn().tw, colors: "r-urgr8i", cText: "r-jwli3a", cTheme: "r-kemksi", cSub: "r-13gxpu9", display: "text + icon", lang: $("html[lang]").attr("lang"), theme: "#000000", translator: 'deepl', }, tetAvatar = 'https://pbs.twimg.com/profile_images/1013798240683266048/zRim1x6M_normal.jpg', sidebar = ` `, get = (url, responseType = 'json', retry = 3) => new Promise((resolve, reject) => { try { GM_xmlhttpRequest({ method: 'GET', url, responseType, onerror: e => { (retry === 0) ? reject(e) : ( log('Network error, retry.'), setTimeout(() => { resolve(get(url, responseType, retry - 1)); }, 1000) ); }, onload: ({ status, response }) => { (status === 200) ? resolve(response) : (retry === 0) ? reject(`${status} ${url}`) : ( log(status, url), setTimeout(() => { resolve(get(url, responseType, retry - 1)); }, 500) ); }, }); } catch (error) { reject(error); } }); //#endregion //#region Site n Menu Fn 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, TETAlt = $("html").attr('lang'), v = en.fn(); (TETSel == 'en' || TETAlt == "en-US") ? (v = en.fn()) : (TETSel == 'bg') ? (v = bg.fn()) : (TETSel == 'cs') ? (v = cs.fn()) : (TETSel == 'da') ? (v = da.fn()) : (TETSel == 'et') ? (v = et.fn()) : (TETSel == 'fi') ? (v = fi.fn()) : (TETSel == 'el') ? (v = el.fn()) : (TETSel == 'hu') ? (v = hu.fn()) : (TETSel == 'lv') ? (v = lv.fn()) : (TETSel == 'lt') ? (v = lt.fn()) : (TETSel == 'ro') ? (v = ro.fn()) : (TETSel == 'sk') ? (v = sk.fn()) : (TETSel == 'sl') ? (v = sl.fn()) : (TETSel == 'sv') ? (v = sv.fn()) : (TETSel == 'zh' || TETAlt == "zh-TW" || TETAlt == "zh-CN") ? (v = zh.fn()) : (TETSel == 'nl') ? (v = nl.fn()) : (TETSel == 'fr') ? (v = fr.fn()) : (TETSel == 'de') ? (v = de.fn()) : (TETSel == 'it') ? (v = it.fn()) : (TETSel == 'ja') ? (v = ja.fn()) : (TETSel == 'pl') ? (v = pl.fn()) : (TETSel == 'pt') ? (v = pt.fn()) : (TETSel == 'ru') ? (v = ru.fn()) : (TETSel == 'es') ? (v = es.fn()) : (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) $('option[value="tweetdeck"]').each(function () { $(this).text(v.df) }) $('option[value="nitter"]').each(function () { $(this).text(v.df) }) TETDisplayChange("demo") }; function TETDisplayChange(mode = "nonrepeat") { let cSel = TETConfig.translator, v = icons.fn(), disA = (cSel == "bingIT") ? (TETConfig.cDisplay = v.azure) : (cSel == "googleIT") ? (TETConfig.cDisplay = v.gCloud) : (cSel == "google") ? (TETConfig.cDisplay = v.google) : (cSel == "bing") ? (TETConfig.cDisplay = v.bing) : (cSel == "mymemory" || cSel == "mymemoryIT") ? (TETConfig.cDisplay = v.mymemory) : (cSel == "translate") ? (TETConfig.cDisplay = v.translate) : (cSel == "yandex") ? (TETConfig.cDisplay = v.yandex) : (TETConfig.cDisplay = v.deepl), disB = (cSel == "mymemoryIT") ? (TETConfig.cDisplay = "MyMemory API") : (cSel == "bingIT") ? (TETConfig.cDisplay = "Azure Cognitive Services") : (cSel == "googleIT") ? (TETConfig.cDisplay = "Google Cloud API") : (cSel == "deeplIT") ? (TETConfig.cDisplay = "DeepL API") : (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"), disC = (cSel == "mymemoryIT") ? (TETConfig.cDisplay = `MyMemory API ${v.mymemory}`) : (cSel == "bingIT") ? (TETConfig.cDisplay = `Azure Cognitive Services ${v.azure}`) : (cSel == "googleIT") ? (TETConfig.cDisplay = `Google Cloud API ${v.gCloud}`) : (cSel == "deeplIT") ? (TETConfig.cDisplay = `DeepL API ${v.deepl}`) : (cSel == "bing") ? (TETConfig.cDisplay = `Bing ${v.bing}`) : (cSel == "google") ? (TETConfig.cDisplay = `Google ${v.google}`) : (cSel == "mymemory") ? (TETConfig.cDisplay = `MyMemory ${v.mymemory}`) : (cSel == "translate") ? (TETConfig.cDisplay = `Translate.com ${v.translate}`) : (cSel == "yandex") ? (TETConfig.cDisplay = `Yandex ${v.yandex}`) : (TETConfig.cDisplay = `DeepL ${v.deepl}`); TETConfig.cDisplay = (TETConfig.display == "icon") ? disA : (TETConfig.display == "text") ? disB : (TETConfig.display == "text + icon") ? disC : log("fuck"); return (mode == "demo") ? ($('#tetDemo').html(`${TETConfig.cLang} ${TETConfig.cDisplay}`)) : ( $('.tet').hover( function() { $(this).toggleClass("r-hover") }, function() { $(this).toggleClass("r-hover") }) ) }; //#endregion //#region Sites function Twitter(btContainer,btLang,site,content = '') { let tetBtn = $(``), 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 vCheck = (TETConfig.api.version == "api-pro") ? 'api' : 'api-free', tweetbtn = () => { log("Injecting tweet button"); btContainer = translateTweet.parent().siblings().eq(0); // [Tweet] Selector btLang = btContainer.attr("lang"); tetBtn.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; 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/machine-translation#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; $('.tet').on("click", async () => { (TETConfig.translator == 'mymemoryIT') ? ( get(`https://api.mymemory.translated.net/get?q=${content}&langpair=${btLang}|${TETConfig.lang}`).then(r => { let res = r.responseData.translatedText, inlineText = $(`
${res}
`); inlineText.appendTo(translateTweet.parent().parent()) })) : (TETConfig.translator == 'googleIT') ? ( get(`https://translation.googleapis.com/language/translate/v2?q=${content}&target=${TETConfig.lang}&source=${btLang}&key=${TETConfig.api.google}`).then(r => { let res = r.data.translations[0], inlineText = $(`
${res.translatedText}
`); inlineText.appendTo(translateTweet.parent().parent()) })) : (TETConfig.translator == 'deeplIT') ? ( get(`https://${vCheck}.deepl.com/v2/translate?auth_key=${TETConfig.api.deepl}&text=${content}&target_lang=${TETConfig.lang}`).then(r => { let res = r.translations[0], inlineText = $(`
${res.text}
`); inlineText.appendTo(translateTweet.parent().parent()) })) : window.open(site,'_blank'); }); TETDisplayChange(); }, biobtn = () => { log("Injecting bio button"); btContainer = translateBio.parent().siblings().eq(0); // [Bio] Selector btLang = "auto"; // [Bio] Language attribute tetBtn.appendTo(translateBio.parent().parent()); btContainer.children("span").each((index,item) => { let bio = $(item).html().trim(); (bio && bio != '' && !isHTML(bio)) ? content+=bio : false; }); 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/machine-translation#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; $('.tet').on("click", async () => { (TETConfig.translator == 'mymemoryIT') ? ( get(`https://api.mymemory.translated.net/get?q=${content}&langpair=${btLang}|${TETConfig.lang}`).then(r => { let res = r.responseData.translatedText, inlineText = $(`
${res}
`); inlineText.appendTo(translateBio.parent().parent()) })) : (TETConfig.translator == 'googleIT') ? ( get(`https://translation.googleapis.com/language/translate/v2?q=${content}&target=${TETConfig.lang}&source=${btLang}&key=${TETConfig.api.google}`).then(r => { let res = r.data.translations[0], inlineText = $(`
${res.translatedText}
`); inlineText.appendTo(translateBio.parent().parent()) })) : (TETConfig.translator == 'deeplIT') ? ( get(`https://${vCheck}.deepl.com/v2/translate?auth_key=${TETConfig.api.deepl}&text=${content}&target_lang=${TETConfig.lang}`).then(r => { let res = r.translations[0], inlineText = $(`
${res.text}
`); inlineText.appendTo(translateBio.parent().parent()) })) : window.open(site,'_blank'); }); TETDisplayChange(); }; (/profile/.test(window.location.href) || /keyboard_shortcuts/.test(window.location.href) || /display/.test(window.location.href) || /video/.test(window.location.href) || /photo/.test(window.location.href) || /compose/.test(window.location.href)) ? $('#tetMenuButton').attr('style', 'display: none !important') : $('#tetMenuButton').attr('style', ''); return (!$('.tet').length && translateBio.length) ? biobtn() : (!$('.tet').length && translateTweet.length) ? tweetbtn() : false; }; function TweetDeck(magicBtn,btContainer,btLang,site,content = '') { let translateTweet = $('a.js-translate-call-to-action'), // "Translate Tweet" button vCheck = (TETConfig.api.version == "api-pro") ? 'api' : 'api-free', 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 magicBtn.addClass( `tet ${TETConfig.cSub}`).html(`${TETConfig.cLang} ${TETConfig.cDisplay}`); (!btLang) ? (btLang = "auto") : false; 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/machine-translation#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", async () => { (TETConfig.translator == 'mymemoryIT') ? ( get(`https://api.mymemory.translated.net/get?q=${content}&langpair=${btLang}|${TETConfig.lang}`).then(r => { let res = r.responseData.translatedText, inlineText = $(`

${res}

`); $('.js-card-container').before(inlineText) })) : (TETConfig.translator == 'googleIT') ? ( get(`https://translation.googleapis.com/language/translate/v2?q=${content}&target=${TETConfig.lang}&source=${btLang}&key=${TETConfig.api.google}`).then(r => { let res = r.data.translations[0], inlineText = $(`

${res.translatedText}

`); $('.js-card-container').before(inlineText) })) : (TETConfig.translator == 'deeplIT') ? ( get(`https://${vCheck}.deepl.com/v2/translate?auth_key=${TETConfig.api.deepl}&text=${content}&target_lang=${TETConfig.lang}`).then(r => { let res = r.translations[0], inlineText = $(`

${res.text}

`); $('.js-card-container').before(inlineText) })) : window.open(site,'_blank'); }); TETDisplayChange(); }, biobtn = () => { log("Injecting bio button"); btContainer = $('p.prf-bio'); content = btContainer.text(); // Content of "Tweet" magicBtn = $(`${TETConfig.cLang} ${TETConfig.cDisplay}`).appendTo(btContainer.parent()); // Create external translation button btLang = "auto" 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/machine-translation#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", async () => { (TETConfig.translator == 'mymemoryIT') ? ( get(`https://api.mymemory.translated.net/get?q=${content}&langpair=${btLang}|${TETConfig.lang}`).then(r => { let res = r.responseData.translatedText, inlineText = $(`

${res}

`); btContainer.parent().before(inlineText) })) : (TETConfig.translator == 'googleIT') ? ( get(`https://translation.googleapis.com/language/translate/v2?q=${content}&target=${TETConfig.lang}&source=${btLang}&key=${TETConfig.api.google}`).then(r => { let res = r.data.translations[0], inlineText = $(`

${res.translatedText}

`); btContainer.parent().before(inlineText) })) : (TETConfig.translator == 'deeplIT') ? ( get(`https://${vCheck}.deepl.com/v2/translate?auth_key=${TETConfig.api.deepl}&text=${content}&target_lang=${TETConfig.lang}`).then(r => { let res = r.translations[0], inlineText = $(`

${res.text}

`); btContainer.parent().before(inlineText) })) : window.open(site,'_blank'); }); TETDisplayChange(); }, checker = () => { (!$('#tet').length && $('div.prf-header').length) ? biobtn() : false; (!$('.tet').length && translateTweet.length) ? tweetbtn() : $('.tet').attr('style', 'display: flex !important; align-items: end !important;'); }; return checker(); }; function Nitter(nBody,site,magicBtn,content = '') { let btLang = "auto", tetBtn = $("#tet"), trTweet = $('#m > div > div > div.tweet-content.media-body'), trBio = $('div.profile-bio > p'), vCheck = (TETConfig.api.version == "api-pro") ? 'api' : 'api-free', tweetbtn = () => { log("Injecting tweet button") nBody = $('#m > div > div > div.tweet-content.media-body') content = nBody.text() // Content of "Tweet" magicBtn = $(`${TETConfig.cLang} ${TETConfig.cDisplay}`).appendTo($('div.container')), // Create external translation button 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/machine-translation#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", async () => { (TETConfig.translator == 'mymemoryIT') ? ( get(`https://api.mymemory.translated.net/get?q=${content}&langpair=${btLang}|${TETConfig.lang}`).then(r => { let res = r.responseData.translatedText, inlineText = $(`
${res}
`); inlineText.appendTo(nBody) })) : (TETConfig.translator == 'googleIT') ? ( get(`https://translation.googleapis.com/language/translate/v2?q=${content}&target=${TETConfig.lang}&source=${btLang}&key=${TETConfig.api.google}`).then(r => { let res = r.data.translations[0], inlineText = $(`
${res.translatedText}
`); inlineText.appendTo(nBody) })) : (TETConfig.translator == 'deeplIT') ? ( get(`https://${vCheck}.deepl.com/v2/translate?auth_key=${TETConfig.api.deepl}&text=${content}&target_lang=${TETConfig.lang}`).then(r => { let res = r.translations[0], inlineText = $(`
${res.text}
`); inlineText.appendTo(nBody) })) : window.open(site,'_blank'); }); TETDisplayChange(); }, biobtn = () => { log("Injecting bio button") nBody = $('div.profile-bio > p') content = trBio.text() // Content of "Tweet" magicBtn = $(`${TETConfig.cLang} ${TETConfig.cDisplay}`).appendTo($('div.container')), // Create external translation button 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/machine-translation#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", async () => { (TETConfig.translator == 'mymemoryIT') ? ( get(`https://api.mymemory.translated.net/get?q=${content}&langpair=${btLang}|${TETConfig.lang}`).then(r => { let res = r.responseData.translatedText, inlineText = $(`
${res}
`); inlineText.appendTo(trBio) })) : (TETConfig.translator == 'googleIT') ? ( get(`https://translation.googleapis.com/language/translate/v2?q=${content}&target=${TETConfig.lang}&source=${btLang}&key=${TETConfig.api.google}`).then(r => { let res = r.data.translations[0], inlineText = $(`
${res.text}
`); inlineText.appendTo(trBio) })) : (TETConfig.translator == 'deeplIT') ? ( get(`https://${vCheck}.deepl.com/v2/translate?auth_key=${TETConfig.api.deepl}&text=${content}&target_lang=${TETConfig.lang}`).then(r => { let res = r.translations[0], inlineText = $(`
${res.text}
`); inlineText.appendTo(trBio) })) : window.open(site,'_blank'); }); TETDisplayChange(); }; return (!tetBtn.length && trTweet.length) ? tweetbtn() : (!tetBtn.length && trBio.length) ? biobtn() : false; }; function TwitLonger() { let content = $('p#posttext').text(),magicBtn,site, btLang = "auto", vCheck = (TETConfig.api.version == "api-pro") ? 'api' : 'api-free', tweetbtn = () => { log("Injecting tweet button"); magicBtn = $(`${TETConfig.cLang} ${TETConfig.cDisplay}`).appendTo($('p.actions.text-right')); 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/machine-translation#${btLang}/${TETConfig.lang}/${content}` : `https://www.deepl.com/translator#${btLang}/${TETConfig.lang}/${content}`; magicBtn.on("click", async () => { (TETConfig.translator == 'googleIT') ? ( get(`https://translation.googleapis.com/language/translate/v2?q=${content}&target=${TETConfig.lang}&source=${btLang}&key=${TETConfig.api.google}`).then(r => { let res = r.data.translations[0], inlineText = $(`
${res.text}
`); inlineText.appendTo($('p.actions.text-right')) })) : (TETConfig.translator == 'deeplIT') ? ( get(`https://${vCheck}.deepl.com/v2/translate?auth_key=${TETConfig.api.deepl}&text=${content}&target_lang=${TETConfig.lang}`).then(r => { let res = r.translations[0], inlineText = $(`
${res.text}
`); inlineText.appendTo($('p.actions.text-right')) })) : window.open(site,'_blank'); }); TETDisplayChange(); }; return (!$("#tet").length && $('p.actions.text-right').length) ? tweetbtn() : false; }; //#endregion //#region Menu function Menu() { try { log("Menu init"); let nav = $('.navbackground'), selLG = qs('select#languages'), selCS = qs('select#colorselect'), selTH = qs('select#theme'), selTR = qs('select#translator'), selDS = qs('select#display'), dlAPI = qs('input.deepl'), goAPI = qs('input.google'), selAPI = qs('select#api-version'), dColor = $(".tetDisplayColor"), tColor = $(".tetTextColor"), tBG = $(".tetBackground"); selLG.value = TETConfig.lang; selCS.value = TETConfig.colors; selTH.value = TETConfig.theme; selTR.value = TETConfig.translator; selDS.value = TETConfig.display; dlAPI.value = TETConfig.api.deepl; goAPI.value = TETConfig.api.google; selAPI.value = TETConfig.api.version; //#region Nitter/TweetDeck (/nitter/.test(window.location.href) || LH == 'twitr.gq' || LH == 'birdsite.xanny.family') ? ( tetAvatar = $(`link[rel="icon"]`).attr("href"), injectCSS(twCSS), $('#tetAvatar').attr('style', `background-image: url("${tetAvatar}");`), $('.tetAvatar').attr('src', tetAvatar), $('.r-demo').toggleClass('demo-TW').toggleClass('demo-NT'), $('div.btNav').attr("id", "tetNT"), selTH.value = "nitter", selCS.value = "nitter", TETConfig.cHover = "tetNitterHover", TETConfig.cColor = "tetNitter", TETConfig.cSub = "tetNText" ) : false; (LH == 'tweetdeck.twitter.com') ? ( TETConfig.cTheme = "r-tetTD", tetAvatar = $(`link[rel="shortcut icon"]`).attr("href"), injectCSS(twCSS), $('#tetAvatar').attr('style', `background-image: url("${tetAvatar}");`), $('.tetAvatar').attr('src', tetAvatar), $('.r-demo').toggleClass('demo-TW').toggleClass('demo-TD'), $('button.tetBtn').each(function () { $(this).addClass("Button--primary") }), $('#tetMenuButton').toggleClass("tetTD"), selTH.value = "tweetdeck", selCS.value = "tweetdeck" ) : false; //#endregion nav.attr("style",`background-color:${TETConfig.cBG}`); tBG.each(function () { $(this).addClass(TETConfig.cTheme) }); tColor.each(function () { $(this).addClass(TETConfig.cText) }); dColor.each(function () { $(this).addClass(TETConfig.colors) }); $('#tetDemo').toggleClass(TETConfig.cSub); (selTR.value == "bingIT") ? ($('.google').hide(),$('.bing').show(),$('.deepl').hide()) : (selTR.value == "googleIT") ? ($('.google').show(),$('.bing').hide(),$('.deepl').hide()) : (selTR.value == "deeplIT") ? ($('.deepl').show(),$('.google').hide(),$('.bing').hide()) : $('.tetFields').hide(); log("Menu functions"); nav.click(function () { $('html').toggleClass('tetFreeze'); $('#tetForm').toggleClass("rm"); $('.btNav').attr('style', 'z-index: -1'); $('svg#tetSVG').show(); $('button#tetMenuButton').attr("style", ""); $('button#tetMenuButton').toggleClass("mini"); $('#tetDemo').toggleClass("rm"); $(this).toggleClass("rm"); autoHide(); }); $('button#tetMenuButton').hover(function() { $('svg#tetSVG').hide(); $(this).toggleClass("mini"); }, function() { $('svg#tetSVG').show(); $(this).toggleClass("mini"); autoHide(); }); qs('button#tetMenuButton').onclick = () => { nav.toggleClass("rm"); $('#tetForm').toggleClass("rm"); $('.btNav').attr('style', 'z-index: 10000 !important'); $('button#tetMenuButton').toggleClass("mini"); $('button#tetMenuButton').attr("style", "display: none !important;"); $('html').toggleClass('tetFreeze'); }; $('button.tetBtn').hover(function() { $(this).toggleClass(TETConfig.cHover).toggleClass(TETConfig.colors); }, function() { $(this).toggleClass(TETConfig.cHover).toggleClass(TETConfig.colors); }); $('div#tetSelector').hover(function() { $(this).toggleClass(`${TETConfig.cColor} r-1kqtdi0`).children("div#tetName").toggleClass(`${TETConfig.cSub} r-9ilb82`); }, function() { $(this).toggleClass(`${TETConfig.cColor} r-1kqtdi0`).children("div#tetName").toggleClass(`${TETConfig.cSub} r-9ilb82`); }); selTH.onchange = () => { let cSel = selTH.value; tBG.toggleClass(TETConfig.cTheme) tColor.toggleClass(TETConfig.cText) TETConfig.cText = "r-jwli3a"; TETConfig.cBG = "rgba(91, 112, 131, 0.4)"; (cSel == "#FFFFFF") ? (TETConfig.cBG = "rgba(0, 0, 0, 0.4)",TETConfig.cTheme = "r-14lw9ot", TETConfig.cText = "r-18jsvk2") : (cSel == "#15202B") ? (TETConfig.cTheme = "r-yfoy6g") : (TETConfig.cTheme = "r-kemksi"); TETConfig.theme = cSel tBG.toggleClass(TETConfig.cTheme) tColor.toggleClass(TETConfig.cText) }; selCS.onchange = () => { let cSel = selCS.value; dColor.toggleClass(TETConfig.colors); $('#tetDemo').toggleClass(TETConfig.cSub); $('.tet').toggleClass(TETConfig.cSub); (cSel == "r-urgr8i") ? (TETConfig.colors = cSel,TETConfig.cHover = "r-1q3imqu",TETConfig.cColor = "r-p1n3y5 r-1bih22f",TETConfig.cSub = "r-13gxpu9") : (cSel == "nitter") ? (TETConfig.colors = cSel,TETConfig.cHover = "tetNitterHover",TETConfig.cColor = "tetNitter",TETConfig.cSub = "tetNText") : (cSel == "r-1vkxrha") ? (TETConfig.colors = cSel,TETConfig.cHover = "r-1kplyi6",TETConfig.cColor = "r-v6khid r-cdj8wb",TETConfig.cSub = "r-61mi1v") : (cSel == "r-1dgebii") ? (TETConfig.colors = cSel,TETConfig.cHover = "r-1ucxkr8",TETConfig.cColor = "r-1iofnty r-jd07pc",TETConfig.cSub = "r-daml9f") : (cSel == "r-1qqlz1x") ? (TETConfig.colors = cSel,TETConfig.cHover = "r-njt2r9",TETConfig.cColor = "r-hy56xe r-11mmphe",TETConfig.cSub = "r-xfsgu1") : (cSel == "r-18z3xeu") ? (TETConfig.colors = cSel,TETConfig.cHover = "r-1kplyi6",TETConfig.cColor = "r-1xl5njo r-b8m25f",TETConfig.cSub = "r-1qkqhnw") : (cSel == "r-b5skir") ? (TETConfig.colors = cSel,TETConfig.cHover = "r-zx61xx",TETConfig.cColor = "r-5ctkeg r-1cqwhho",TETConfig.cSub = "r-nw8l94") : (TETConfig.colors = cSel,TETConfig.cHover = "r-1q3imqu",TETConfig.cColor = "r-p1n3y5 r-1bih22f",TETConfig.cSub = "r-13gxpu9"); $('.tet').toggleClass(TETConfig.cSub); $('#tetDemo').toggleClass(TETConfig.cSub); dColor.toggleClass(TETConfig.colors); }; selLG.onchange = () => { TETLanguageChange(); TETConfig.lang = selLG.value; }; selTR.onchange = () => { TETConfig.translator = selTR.value; (selTR.value == "bingIT") ? ($('.google').hide(),$('.bing').show(),$('.deepl').hide()) : (selTR.value == "googleIT") ? ($('.google').show(),$('.bing').hide(),$('.deepl').hide()) : (selTR.value == "deeplIT") ? ($('.deepl').show(),$('.google').hide(),$('.bing').hide()) : $('.tetFields').hide(); TETDisplayChange("demo"); }; selDS.onchange = () => { TETConfig.display = selDS.value; TETDisplayChange("demo"); }; selAPI.onchange = () => { TETConfig.api.google = goAPI.value; TETConfig.api.deepl = dlAPI.value; TETConfig.api.version = selAPI.value; }; qs('button#tetSave').onclick = async () => { TETConfig.api.google = goAPI.value; TETConfig.api.deepl = dlAPI.value; 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) }; log("Checking for language changes"); (TETConfig.lang != "en" || TETConfig.lang != "en-US") ? TETLanguageChange() : false; autoHide(); } catch (e) { (!enableLogs) ? (enableLogs = true) : false; TETConfig = DefaultConfig; TETSetValue("Config", JSON.stringify(TETConfig)) log(e); } }; //#endregion //#region Init Userscript await Promise.all([GM.getValue("Config")]).then((data) => { let res = data[0]; res ?? log("First time init."),TETConfig = DefaultConfig; res ? () => { try { TETConfig = JSON.parse(res); } catch (e) { TETConfig = res; } } : false; 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]); } log("Config Loaded"); injectCSS(tetCSS); let body = $("body"); body.prepend(sidebar); Menu(); log("Starting TET Injection"); TETInject; }).catch((e) => { (!enableLogs) ? (enableLogs = true) : false; TETConfig = DefaultConfig; log(e); }) })(); //#endregion