Google 伪装成 百度

中国人就用百度搜索

  1. // ==UserScript==
  2. // @name Google 伪装成 百度
  3. // @namespace https://github.com/userElaina/this-is-the-China-website
  4. // @version 2024.04.01.01
  5. // @description 中国人就用百度搜索
  6. // @author somereason userElaina
  7. // @license MIT
  8. // @match *://*.google.com/
  9. // @match *://*.google.com/webhp*
  10. // @match *://*.google.com/search*
  11. // @match *://*.google.com/imghp*
  12. // @match *://scholar.google.com/*
  13. // @match *://*.google.com.hk/
  14. // @match *://*.google.com.hk/webhp*
  15. // @match *://*.google.com.hk/search*
  16. // @match *://*.google.com.hk/imghp*
  17. // @match *://scholar.google.com.hk/*
  18. // @match *://*.google.com.tw/
  19. // @match *://*.google.com.tw/webhp*
  20. // @match *://*.google.com.tw/search*
  21. // @match *://*.google.com.tw/imghp*
  22. // @match *://scholar.google.com.tw/*
  23. // @match *://*.google.co.jp/
  24. // @match *://*.google.co.jp/webhp*
  25. // @match *://*.google.co.jp/search*
  26. // @match *://*.google.co.jp/imghp*
  27. // @match *://scholar.google.co.jp/*
  28. // @grant none
  29. // ==/UserScript==
  30.  
  31. function sleep(time) {
  32. return new Promise((resolve) => setTimeout(resolve, time));
  33. }
  34.  
  35. async function f_succ(f, msSleep = 500, maxCount = 10) {
  36. let count = 0;
  37. while (true) {
  38. if (f()) {
  39. return true;
  40. }
  41. count++;
  42. if (count > maxCount) {
  43. return false;
  44. }
  45. await sleep(msSleep);
  46. }
  47. }
  48.  
  49. (async function () {
  50. // change icon
  51. let link = document.querySelector("link[rel*='icon']") || document.createElement('link');
  52. link.type = 'image/x-icon';
  53. link.rel = 'shortcut icon';
  54. link.href = 'https://raw.githubusercontent.com/userElaina/this-is-the-China-website/main/google/baidu.ico';
  55. document.getElementsByTagName('head')[0].appendChild(link);
  56.  
  57. // change search style
  58. f_succ(() => {
  59. let RNNXgb = document.getElementsByClassName('RNNXgb');
  60. if (RNNXgb.length <= 0) {
  61. RNNXgb = document.getElementsByClassName('o6juZc');
  62. }
  63. if (RNNXgb.length <= 0) {
  64. return false;
  65. }
  66. let searchStyle = RNNXgb[0].style;
  67. searchStyle.boxShadow = "0 0 0 0";
  68. searchStyle.border = 0;
  69. searchStyle.borderRadius = 0;
  70. searchStyle.background = '#4e6ef21f';
  71. return true;
  72. });
  73.  
  74. // func: change search button
  75. async function SearchButton(s0) {
  76. await f_succ(() => {
  77. let Tg7LZd = document.getElementsByClassName('Tg7LZd');
  78. if (Tg7LZd.length <= 0) {
  79. Tg7LZd = document.getElementsByClassName('rCGXm');
  80. }
  81. if (Tg7LZd.length <= 0) {
  82. return false;
  83. }
  84. let height = Tg7LZd[0].clientHeight;
  85. Tg7LZd[0].innerHTML = '<img height=' + height + ' src="https://raw.githubusercontent.com/userElaina/this-is-the-China-website/main/google/' + s0 + '.png">';
  86. return true;
  87. });
  88. }
  89.  
  90. // func: change big logo
  91. async function BigLogo(str) {
  92. await f_succ(() => {
  93. let bannerLogo = document.querySelector("[alt='" + str + "']");
  94. if (bannerLogo === null) {
  95. return false;
  96. }
  97. bannerLogo.src = "https://raw.githubusercontent.com/userElaina/this-is-the-China-website/main/google/baidu_big.png";
  98. bannerLogo.removeAttribute("srcset");
  99. bannerLogo.width = 117 * 2;
  100. bannerLogo.height = 38 * 2;
  101. /*
  102. let paddingTop = bannerLogo.style.paddingTop.replace("px", "");
  103. let paddingTopInt = parseInt(paddingTop);
  104. bannerLogo.style.paddingTop = (paddingTopInt - 20) + "px";
  105. */
  106. return true;
  107. });
  108. }
  109.  
  110. if (window.location.href.indexOf("/search") > -1) {
  111. // search page
  112.  
  113. // change search logo
  114. f_succ(() => {
  115. let logo = document.getElementById("logo");
  116. let logoArr;
  117. if (logo === null) {
  118. logoArr = document.getElementsByClassName("logo");
  119. if (logoArr.length <= 0) {
  120. logoArr = document.getElementsByClassName("logocont");
  121. if (logoArr.length <= 0) {
  122. logoArr = document.getElementsByClassName("qlS7ne");
  123. }
  124. }
  125. if (logoArr.length > 0) {
  126. logo = logoArr[0];
  127. }
  128. }
  129. if (logo === null) {
  130. return false;
  131. }
  132. let img = logo.querySelector("img");
  133. if (img === null) {
  134. if (logo.childElementCount <= 0) {
  135. return false;
  136. }
  137. logo.childNodes[0].innerHTML = '<img src="https://raw.githubusercontent.com/userElaina/this-is-the-China-website/main/google/baidu_big.png" style="background:none" height="30" width="92" data-atf="1" data-frt="0"></img>';
  138. } else {
  139. img.src = 'https://raw.githubusercontent.com/userElaina/this-is-the-China-website/main/google/baidu_big.png';
  140. }
  141. return true;
  142. });
  143.  
  144. document.title = document.title.replace(/\s-[\s\S]*/g, " - 百度搜索");
  145. SearchButton('search');
  146.  
  147. let naviImageUrl = "https://raw.githubusercontent.com/userElaina/this-is-the-China-website/main/google/icons.png";
  148. let navTabSpans = document.getElementsByClassName("SJajHc");
  149. for (let i = 0; i < navTabSpans.length; i++) {
  150. navTabSpans[i].style.width = "22px";
  151. if (i === 0) {
  152. navTabSpans[i].style.background = 'url("' + naviImageUrl + '") no-repeat 0px 0px';
  153. } else if (i == navTabSpans.length - 1) {
  154. navTabSpans[i].style.background = 'url("' + naviImageUrl + '") no-repeat 0px 0px';
  155. } else if (navTabSpans[i].classList.contains("NVbCr")) {
  156. navTabSpans[i].style.background = i % 2 == 1 ? 'url("' + naviImageUrl + '") no-repeat -144px -288px' : 'url("' + naviImageUrl + '") no-repeat -144px -282px';
  157. } else {
  158. navTabSpans[i].style.background = 'url("' + naviImageUrl + '") no-repeat -96px -288px';
  159. }
  160. }
  161.  
  162. } else if (window.location.href.indexOf("/imghp") > -1) {
  163. // Google Images
  164.  
  165. BigLogo('Google Images');
  166. document.title = "百度图片, 发现多彩世界";
  167. SearchButton('imghp');
  168. f_succ(() => {
  169. let T8VaVe = document.getElementsByClassName("T8VaVe");
  170. if (T8VaVe.length <= 0) {
  171. return false;
  172. }
  173. T8VaVe[0].innerHTML = '';
  174. return true;
  175. });
  176.  
  177. } else if (window.location.href.indexOf("scholar") > -1) {
  178.  
  179. if (window.location.href.indexOf("/scholar?") > -1) {
  180. document.title = document.title.replace(/\s-[\s\S]*/g, " - 百度学术");
  181. f_succ(() => {
  182. let gs_hdr_lgo = document.getElementById("gs_hdr_lgo");
  183. if (gs_hdr_lgo === null) {
  184. return false;
  185. }
  186. gs_hdr_lgo.remove();
  187. return true;
  188. });
  189. } else {
  190. document.title = "百度学术 - 保持学习的态度";
  191. f_succ(() => {
  192. let gs_hdr_hp_lgo = document.getElementById("gs_hdr_hp_lgo");
  193. if (gs_hdr_hp_lgo === null) {
  194. return false;
  195. }
  196. gs_hdr_hp_lgo.srcset = "https://raw.githubusercontent.com/userElaina/this-is-the-China-website/main/google/scholar.png";
  197. return true;
  198. });
  199. }
  200.  
  201. // } else if (window.location.href.indexOf("/webhp") > -1) {
  202. // same as main page, reached by clicking on the logo
  203. } else {
  204. // main page
  205.  
  206. BigLogo('Google');
  207. document.title = "百度一下, 你就知道";
  208.  
  209. document.querySelectorAll('a.gb_d, a.gb_p, a.gb_q, a.gb_F, a.gb_H').forEach(v => {
  210. if (v.dataset.pid === '2') {
  211. v.innerText = '百度识图';
  212. if (v.href.indexOf("google.cn") > -1) {
  213. v.href = 'https://images.google.com/imghp';
  214. }
  215. } else if (v.dataset.pid === '23') {
  216. v.innerHTML = '百度邮箱';
  217. }
  218. });
  219.  
  220. document.querySelectorAll('span.gb_Id').forEach(v => {
  221. v.innerHTML = '登录(不可用)';
  222. });
  223.  
  224. // 关于百度 广告 商务 百度搜索的运作方式 隐私权 条款 设置
  225. document.querySelectorAll("a.pHiOh").forEach(v => {
  226. v.innerHTML = v.innerHTML.replace(/\s?Google\s?/, "百度");
  227. });
  228.  
  229. /*
  230. document.getElementsByClassName("Fx4vi").forEach(v =>{
  231. v.innerHTML = v.innerHTML.replace(/Google\s?/, "百度");
  232. });
  233. */
  234.  
  235. f_succ(() => {
  236. let btnK = document.getElementsByName("btnK")
  237. if (btnK.length <= 0) {
  238. return false;
  239. }
  240. btnK.forEach(v => {
  241. v.value = "百度搜索";
  242. });
  243. return true;
  244. });
  245.  
  246. f_succ(() => {
  247. let btnI = document.getElementsByName("btnI")
  248. if (btnI.length <= 0) {
  249. return false;
  250. }
  251. btnI.forEach(v => {
  252. v.value = "今日运势";
  253. });
  254. return true;
  255. });
  256.  
  257. f_succ(() => {
  258. let footnote = document.getElementById("SIvCob");
  259. if (footnote === null) {
  260. return false;
  261. }
  262. footnote.innerHTML = '百度提供: ' + footnote.innerHTML.slice(footnote.innerHTML.indexOf('<'));
  263. return true;
  264. });
  265.  
  266. // Google 区域改为京 ICP 备
  267. document.querySelectorAll("div.uU7dJb").forEach(v => {
  268. v.innerHTML = v.innerHTML.replace(/.*/, "广公网信备11011101111101号 广IPC证01048576号");
  269. });
  270.  
  271. }
  272.  
  273. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址