Better cametek.jp

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

目前为 2024-08-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better cametek.jp
  3. // @author NarwhalKid
  4. // @namespace https://github.com/KFxxx/xxxx/blob/main/GT.js
  5. // @description 自動(可關閉)網頁翻譯(預設為其他語言自動轉繁體)
  6. // @description:en Better camtek.jp
  7. // @version 0.03
  8. // @license CC v4.0 https://creativecommons.org/licenses/by/4.0/
  9. // @match https://cametek.jp/*
  10. // @match https://nanahira.jp/*
  11. // @match http://camtek.seesaa.net/*
  12. // @match http://www.studiosatuki.com/*
  13. // @match http://younoumi.com/*
  14. // @match https://www.tanocstore.net/*
  15. // @match http://tenjemi.com/*
  16. // @match http://www.orc2000.com/*
  17. // @match http://wakusei.birdtune.jp/*
  18. // @match http://alst.net/*
  19. // @match http://confetto.chu.jp/*
  20. // @match http://holicservice.com/*
  21. // @match https://www.nicovideo.jp/*
  22. // @match https://live.nicovideo.jp/*
  23. // @match http://movementonthefloor.net/*
  24. // @match http://downforce.jp/*
  25. // @match http://innocent-key.com/*
  26. // @match https://www.voiceblog.jp/*
  27. // @match http://www.vocalomakets.com/*
  28. // @match http://www.ugc-pub.com/*
  29. // @match https://www.iosysos.com/*
  30. // @match http://djgenki.net/*
  31. // @match http://usao926.blog.fc2.com/*
  32. // @match http://www.tano-c.net/*
  33. // @match http://www.sketchuprecordings.com/*
  34. // @match http://club-mixus.com/*
  35. // @match http://tweetvite.com/*
  36. // @match http://forestpireo.jp/*
  37. // @match https://sparkle-of-voices.tumblr.com/*
  38. // @match https://twipla.jp/*
  39. // @match http://phquase.web.fc2.com/*
  40. // @match http://beatlogic.jp/*
  41. // @match http://zytokine-web.com/*
  42. // @match http://soundave.net/*
  43. // @match https://www.stpaulsigncompany.com/*
  44. // @match https://ameblo.jp/*
  45. // @match https://iosystrax.com/*
  46. // @match http://blog.livedoor.jp/*
  47. // @match http://www.dtmm.co.jp/*
  48. // @match http://diverse.jp/*
  49. // @match http://spriterecordings.upper.jp/*
  50. // @match http://www.cubegrams.com/*
  51. // @match https://www.rittor-music.co.jp/*
  52. // @match http://vocalabo.web.fc2.com/*
  53. // @match http://c-h-s.me/holix/
  54. // @match http://zytokine-web.com/*
  55. // @match http://www.tamstarrecords.jp/*
  56. // @match https://dx-penguin.tumblr.com/*
  57. // @match https://club-mogra.jp/*
  58. // @match https://twipla.jp/*
  59. // @match http://ototonekoushiki.wix.com/*
  60. // @match http://nagomix.co.jp/*
  61. // @match http://binzo.co/*
  62. // @match https://hkcd-0008.tumblr.com/*
  63. // @match https://shandybass2.tumblr.com/*
  64. // @match http://movementonthefloor.net/*
  65. // @match https://error.fc2.com/*
  66. // @match https://kc-versus.tumblr.com/*
  67. // @match http://massivecirclez.jp/*
  68. // @match http://www.otoculture.com/*
  69. // @match http://r135.net/*
  70. // @icon https://cametek.jp/img/cametekjp.ico
  71. // @run-at document-end
  72. // @note 20211101 v0.02 --- 補上一開始忘記加上消除 text hover 時候煩人的 tipssss
  73. // ==/UserScript==
  74. ;(function () {
  75. "use strict"
  76. // 抓網頁使用的語言
  77. const pLang = document.documentElement.lang.toLowerCase().substr(0,5);
  78. // 抓自己使用的語言
  79. const uLang = (navigator.language||navigator.browserLanguage).toLowerCase().substr(0,5);
  80. // 空 DIV
  81. let xdiv = document.createElement("div");
  82. xdiv.id = "google_translate_element";
  83. // 本體 CSS
  84. let xcss = document.createElement("style");
  85. 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;}";
  86. // 關閉按鈕
  87. let button = document.createElement("button");
  88. button.innerHTML = "取消翻譯";
  89. button.id = "xcancel";
  90. button.onclick = function(){
  91. let iframe = document.getElementsByClassName("goog-te-banner-frame")[0];
  92. if(!iframe)return;
  93. let innerDoc = iframe.contentDocument||iframe.contentWindow.document;
  94. let restore_el = innerDoc.getElementsByTagName("button");
  95. for(let i=0;i<restore_el.length;i++){
  96. if(restore_el[i].id.indexOf("restore")>=0) {
  97. restore_el[i].click();
  98. let close_el = innerDoc.getElementsByClassName("goog-close-link");
  99. close_el[0].click();
  100. return;}
  101. }
  102. };
  103. //Get link
  104. let endurl = window.location.href.split('/',3)
  105. let fc2 = window.location.href.split('/',5)
  106. //Get archive if any of these links
  107. if ((endurl == 'http:,,www.studiosatuki.com') || (endurl == 'http:,,forestpireo.jp') || (endurl == 'https:,,www.tanocstore.net') || (endurl == 'http:,,alst.net') || (endurl == 'http:,,downforce.jp') || (endurl == 'http:,,movementonthefloor.net') || (endurl == 'http:,,innocent-key.com') || (endurl == 'https:,,www.voiceblog.jp') || (endurl == 'http:,,www.ugc-pub.com') || (endurl == 'http:,,club-mixus.com') || (endurl == 'http:,,soundave.net') || (endurl == 'http:,,www.dtmm.co.jp') || (endurl == 'https:,,twipla.jp') || (endurl == 'http:,,movementonthefloor.net') || (endurl == 'http:,,www.otoculture.com') || (endurl == 'http:,,r135.net')) {
  108. window.location.href = "https://web.archive.org/web/*/" + window.location.href
  109. }
  110. if (fc2 == 'https:,,error.fc2.com,web,404.html') {
  111. window.location.href = "https://web.archive.org/web/*/http://phquase.web.fc2.com/cd/pqcd_0002_quarnival.html"
  112. }
  113. if (endurl == 'https:,,www.iosysos.com') {
  114. window.location.href = "https://www.narwhalkid.com/iosysos/"
  115. }
  116. if (endurl == 'https:,,www.stpaulsigncompany.com' || endurl == 'http:,,massivecirclez.jp') {
  117. window.location.href = "https://www.narwhalkid.com/massivecirclez/"
  118. }
  119. if (endurl == 'https:,,iosystrax.com') {
  120. window.location.href = "https://web.archive.org/web/*/http://iosystrax.com/2013/08/11/iopakiba2013-2/"
  121. }
  122. if (endurl == 'http:,,ototonekoushiki.wix.com') {
  123. window.location.href = "https://www.narwhalkid.com/hensyuu1/"
  124. }
  125.  
  126. // 翻譯選單/本體
  127. function googleTranslateElementInit(){
  128. new google.translate.TranslateElement({
  129. pageLanguage:"auto",
  130. // 可翻譯的語言,繁簡中,英語,日語,法語
  131. includedLanguages: "en,fr",
  132. },"google_translate_element");
  133. document.body.appendChild(button);
  134. setTimeout(function(){
  135. var select = document.querySelector("select.goog-te-combo");
  136. // 自動翻譯語言
  137. select.value = "en";
  138. select.dispatchEvent(new Event("change"));
  139. // 刪除顯示原文 POP
  140. var xpopx = document.getElementById("goog-gt-tt");
  141. xpopx.parentNode.removeChild(xpopx);
  142. },100);
  143. };
  144. (function() {
  145. var googleTranslateScript = document.createElement("script");
  146. googleTranslateScript.type = "text/javascript";
  147. googleTranslateScript.async = true;
  148. googleTranslateScript.src = "https://translate.google.com/translate_a/element.js";
  149. ( document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0] ).appendChild( googleTranslateScript );
  150. })();
  151. if(pLang==uLang){
  152. // 使用者語言與網頁相同不動作
  153. } else if (pLang!==uLang){
  154. // 網頁語言不是指定語言:寫入
  155. window.onload = googleTranslateElementInit;
  156. document.body.appendChild(xdiv);
  157. document.head.appendChild(xcss);
  158. }else{
  159. // 其他
  160. };
  161. })()