Google網頁翻譯

自動(可關閉)網頁翻譯(預設為其他語言自動轉繁體)

目前為 2024-03-20 提交的版本,檢視 最新版本

作者
KF xxx
評價
0 0 0
版本
0.02
建立日期
2021-10-31
更新日期
2024-03-20
尺寸
3.6 KB
授權條款
CC v4.0 https://creativecommons.org/licenses/by/4.0/
腳本執行於
所有網站

{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"2875363.png","path":"2875363.png","contentType":"file"},{"name":"GT.js","path":"GT.js","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"dew-point--v22.gif","path":"dew-point--v22.gif","contentType":"file"}],"totalCount":5}},"fileTreeProcessingTime":7.712189,"foldersToFetch":[],"repo":{"id":423036913,"defaultBranch":"main","name":"xxxx","ownerLogin":"KFxxx","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2021-10-31T02:43:00.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/66585559?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"main","listCacheKey":"v0:1647495719.3151932","canEdit":false,"refType":"branch","currentOid":"ff42c58d14daad8c87983cbc99ccb599f0907d9a"},"path":"GT.js","currentUser":null,"blob":{"rawLines":["// ==UserScript==","// @name Google網頁翻譯","// @name:en Google Translate for browser ","// @author KFxxx","// @namespace https://github.com/KFxxx/xxxx/blob/main/GT.js","// @description 自動(可關閉)網頁翻譯(預設為其他語言自動轉繁體)","// @description:en Google Translate for browser.. ","// @version 0.02","// @license CC v4.0 https://creativecommons.org/licenses/by/4.0/","// @icon https://raw.githubusercontent.com/KFxxx/xxxx/main/2875363.png","// @include *","// @run-at document-end","// @note 20211101 v0.02 --- 補上一開始忘記加上消除 text hover 時候煩人的 tipssss","// ==/UserScript==",";(function () {"," \"use strict\""," // 抓網頁使用的語言"," const pLang = document.documentElement.lang.toLowerCase().substr(0,5);"," // 抓自己使用的語言"," const uLang = (navigator.language||navigator.browserLanguage).toLowerCase().substr(0,5);"," // 空 DIV"," let xdiv = document.createElement(\"div\");"," xdiv.id = \"google_translate_element\";"," // 本體 CSS"," let xcss = document.createElement(\"style\");"," xcss.innerHTML = \".goog-text-highlight{background-color:transparent!important;border:none!important;box-shadow:none!important;}body{top:0px!important;}.goog-te-banner-frame.skiptranslate{display:none!important;}select.goog-te-combo,#xcancel{z-index: 88888888;opacity:0.5;position:fixed;font-size:8px; font-weight:bold;width:90px;left:5px;top:55px;color:#666;background:#f8f8f8;border:solid #aaa 2px;}#xcancel{top:85px;opacity:0;}select.goog-te-combo:hover,#xcancel:hover{opacity:1;}#google_translate_element{display:block;width:0px;overflow:hidden;}\";"," // 關閉按鈕"," let button = document.createElement(\"button\");"," button.innerHTML = \"取消翻譯\";"," button.id = \"xcancel\";"," button.onclick = function(){"," let iframe = document.getElementsByClassName(\"goog-te-banner-frame\")[0];"," if(!iframe)return;"," let innerDoc = iframe.contentDocument||iframe.contentWindow.document;"," let restore_el = innerDoc.getElementsByTagName(\"button\");"," for(let i=0;i=0) {"," restore_el[i].click();"," let close_el = innerDoc.getElementsByClassName(\"goog-close-link\");"," close_el[0].click();"," return;}"," }"," };"," // 翻譯選單/本體"," function googleTranslateElementInit(){"," new google.translate.TranslateElement({"," pageLanguage:\"auto\","," // 可翻譯的語言,繁簡中,英語,日語,法語"," includedLanguages: \"zh-TW,zh-CN,en,ja,fr\","," },\"google_translate_element\");"," document.body.appendChild(button);"," setTimeout(function(){"," var select = document.querySelector(\"select.goog-te-combo\");"," // 自動翻譯語言"," select.value = \"zh-TW\";"," select.dispatchEvent(new Event(\"change\"));"," // 刪除顯示原文 POP"," var xpopx = document.getElementById(\"goog-gt-tt\");"," xpopx.parentNode.removeChild(xpopx);"," },100);"," };"," (function() {"," var googleTranslateScript = document.createElement(\"script\");"," googleTranslateScript.type = \"text/javascript\";"," googleTranslateScript.async = true;"," googleTranslateScript.src = \"https://translate.google.com/translate_a/element.js\";"," ( document.getElementsByTagName(\"head\")[0] || document.getElementsByTagName(\"body\")[0] ).appendChild( googleTranslateScript );"," })();"," if(pLang==uLang){"," // 使用者語言與網頁相同不動作"," } else if (pLang!==uLang){"," // 網頁語言不是指定語言:寫入"," window.onload = googleTranslateElementInit;"," document.body.appendChild(xdiv);"," document.head.appendChild(xcss);"," }else{"," // 其他"," };","})()"],"stylingDirectives":[[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]],"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/KFxxx/xxxx/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"GT.js","displayUrl":"https://github.com/KFxxx/xxxx/blob/main/GT.js?raw=true","headerInfo":{"blobSize":"3.59 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"955458d","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2FKFxxx%2Fxxxx%2Fblob%2Fmain%2FGT.js","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"79","truncatedSloc":"79"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"JavaScript","languageID":183,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/KFxxx/xxxx/blob/main/GT.js","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/KFxxx/xxxx/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/KFxxx/xxxx/raw/main/GT.js","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"onclick","kind":"function","ident_start":1802,"ident_end":1809,"extent_start":1795,"extent_end":2312,"fully_qualified_name":"onclick","ident_utf16":{"start":{"line_number":30,"utf16_col":9},"end":{"line_number":30,"utf16_col":16}},"extent_utf16":{"start":{"line_number":30,"utf16_col":2},"end":{"line_number":42,"utf16_col":3}}},{"name":"googleTranslateElementInit","kind":"function","ident_start":2350,"ident_end":2376,"extent_start":2341,"extent_end":2991,"fully_qualified_name":"googleTranslateElementInit","ident_utf16":{"start":{"line_number":44,"utf16_col":11},"end":{"line_number":44,"utf16_col":37}},"extent_utf16":{"start":{"line_number":44,"utf16_col":2},"end":{"line_number":60,"utf16_col":3}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"csrf_tokens":{"/KFxxx/xxxx/branches":{"post":"IswwCJ3NDMKyinKdHez38c089WOd-rxN_65B08Zvp1hwPcUuQ6aJqM8wDqbWEL1xUdnGmBXLyVqW0NstH8IZaQ"},"/repos/preferences":{"post":"IodzDTFulkzRJM65BRc2K-fKXcF1u40dIUw9KSK-SjjBKJK9rGCthbCcKGB56jBI7_-j-GoG-62ol9oFucO8SQ"}}},"title":"xxxx/GT.js at main · KFxxx/xxxx"}