谷Bing圖

給 Google 首頁換上 Bing 的背景圖

目前為 2024-08-21 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name BingBgForGoogle
  3. // @name:zh-CN 谷Bing图
  4. // @name:zh-TW 谷Bing圖
  5. // @namespace hoothin
  6. // @version 0.2
  7. // @description Just change the background image of Google homepage to Bing
  8. // @description:zh-CN 给谷歌首页换上 Bing 的背景图
  9. // @description:zh-TW 給 Google 首頁換上 Bing 的背景圖
  10. // @author hoothin
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // @grant GM_addStyle
  15. // @grant unsafeWindow
  16. // @connect global.bing.com
  17. // @connect cn.bing.com
  18. // @license MIT License
  19. // @match *://www.google.com/*
  20. // @match *://www.google.ad/*
  21. // @match *://www.google.ae/*
  22. // @match *://www.google.com.af/*
  23. // @match *://www.google.com.ag/*
  24. // @match *://www.google.al/*
  25. // @match *://www.google.am/*
  26. // @match *://www.google.co.ao/*
  27. // @match *://www.google.com.ar/*
  28. // @match *://www.google.as/*
  29. // @match *://www.google.at/*
  30. // @match *://www.google.com.au/*
  31. // @match *://www.google.az/*
  32. // @match *://www.google.ba/*
  33. // @match *://www.google.com.bd/*
  34. // @match *://www.google.be/*
  35. // @match *://www.google.bf/*
  36. // @match *://www.google.bg/*
  37. // @match *://www.google.com.bh/*
  38. // @match *://www.google.bi/*
  39. // @match *://www.google.bj/*
  40. // @match *://www.google.com.bn/*
  41. // @match *://www.google.com.bo/*
  42. // @match *://www.google.com.br/*
  43. // @match *://www.google.bs/*
  44. // @match *://www.google.bt/*
  45. // @match *://www.google.co.bw/*
  46. // @match *://www.google.by/*
  47. // @match *://www.google.com.bz/*
  48. // @match *://www.google.ca/*
  49. // @match *://www.google.cd/*
  50. // @match *://www.google.cf/*
  51. // @match *://www.google.cg/*
  52. // @match *://www.google.ch/*
  53. // @match *://www.google.ci/*
  54. // @match *://www.google.co.ck/*
  55. // @match *://www.google.cl/*
  56. // @match *://www.google.cm/*
  57. // @match *://www.google.cn/*
  58. // @match *://www.google.com.co/*
  59. // @match *://www.google.co.cr/*
  60. // @match *://www.google.com.cu/*
  61. // @match *://www.google.cv/*
  62. // @match *://www.google.com.cy/*
  63. // @match *://www.google.cz/*
  64. // @match *://www.google.de/*
  65. // @match *://www.google.dj/*
  66. // @match *://www.google.dk/*
  67. // @match *://www.google.dm/*
  68. // @match *://www.google.com.do/*
  69. // @match *://www.google.dz/*
  70. // @match *://www.google.com.ec/*
  71. // @match *://www.google.ee/*
  72. // @match *://www.google.com.eg/*
  73. // @match *://www.google.es/*
  74. // @match *://www.google.com.et/*
  75. // @match *://www.google.fi/*
  76. // @match *://www.google.com.fj/*
  77. // @match *://www.google.fm/*
  78. // @match *://www.google.fr/*
  79. // @match *://www.google.ga/*
  80. // @match *://www.google.ge/*
  81. // @match *://www.google.gg/*
  82. // @match *://www.google.com.gh/*
  83. // @match *://www.google.com.gi/*
  84. // @match *://www.google.gl/*
  85. // @match *://www.google.gm/*
  86. // @match *://www.google.gr/*
  87. // @match *://www.google.com.gt/*
  88. // @match *://www.google.gy/*
  89. // @match *://www.google.com.hk/*
  90. // @match *://www.google.hn/*
  91. // @match *://www.google.hr/*
  92. // @match *://www.google.ht/*
  93. // @match *://www.google.hu/*
  94. // @match *://www.google.co.id/*
  95. // @match *://www.google.ie/*
  96. // @match *://www.google.co.il/*
  97. // @match *://www.google.im/*
  98. // @match *://www.google.co.in/*
  99. // @match *://www.google.iq/*
  100. // @match *://www.google.is/*
  101. // @match *://www.google.it/*
  102. // @match *://www.google.je/*
  103. // @match *://www.google.com.jm/*
  104. // @match *://www.google.jo/*
  105. // @match *://www.google.co.jp/*
  106. // @match *://www.google.co.ke/*
  107. // @match *://www.google.com.kh/*
  108. // @match *://www.google.ki/*
  109. // @match *://www.google.kg/*
  110. // @match *://www.google.co.kr/*
  111. // @match *://www.google.com.kw/*
  112. // @match *://www.google.kz/*
  113. // @match *://www.google.la/*
  114. // @match *://www.google.com.lb/*
  115. // @match *://www.google.li/*
  116. // @match *://www.google.lk/*
  117. // @match *://www.google.co.ls/*
  118. // @match *://www.google.lt/*
  119. // @match *://www.google.lu/*
  120. // @match *://www.google.lv/*
  121. // @match *://www.google.com.ly/*
  122. // @match *://www.google.co.ma/*
  123. // @match *://www.google.md/*
  124. // @match *://www.google.me/*
  125. // @match *://www.google.mg/*
  126. // @match *://www.google.mk/*
  127. // @match *://www.google.ml/*
  128. // @match *://www.google.com.mm/*
  129. // @match *://www.google.mn/*
  130. // @match *://www.google.com.mt/*
  131. // @match *://www.google.mu/*
  132. // @match *://www.google.mv/*
  133. // @match *://www.google.mw/*
  134. // @match *://www.google.com.mx/*
  135. // @match *://www.google.com.my/*
  136. // @match *://www.google.co.mz/*
  137. // @match *://www.google.com.na/*
  138. // @match *://www.google.com.ng/*
  139. // @match *://www.google.com.ni/*
  140. // @match *://www.google.ne/*
  141. // @match *://www.google.nl/*
  142. // @match *://www.google.no/*
  143. // @match *://www.google.com.np/*
  144. // @match *://www.google.nr/*
  145. // @match *://www.google.nu/*
  146. // @match *://www.google.co.nz/*
  147. // @match *://www.google.com.om/*
  148. // @match *://www.google.com.pa/*
  149. // @match *://www.google.com.pe/*
  150. // @match *://www.google.com.pg/*
  151. // @match *://www.google.com.ph/*
  152. // @match *://www.google.com.pk/*
  153. // @match *://www.google.pl/*
  154. // @match *://www.google.pn/*
  155. // @match *://www.google.com.pr/*
  156. // @match *://www.google.ps/*
  157. // @match *://www.google.pt/*
  158. // @match *://www.google.com.py/*
  159. // @match *://www.google.com.qa/*
  160. // @match *://www.google.ro/*
  161. // @match *://www.google.ru/*
  162. // @match *://www.google.rw/*
  163. // @match *://www.google.com.sa/*
  164. // @match *://www.google.com.sb/*
  165. // @match *://www.google.sc/*
  166. // @match *://www.google.se/*
  167. // @match *://www.google.com.sg/*
  168. // @match *://www.google.sh/*
  169. // @match *://www.google.si/*
  170. // @match *://www.google.sk/*
  171. // @match *://www.google.com.sl/*
  172. // @match *://www.google.sn/*
  173. // @match *://www.google.so/*
  174. // @match *://www.google.sm/*
  175. // @match *://www.google.sr/*
  176. // @match *://www.google.st/*
  177. // @match *://www.google.com.sv/*
  178. // @match *://www.google.td/*
  179. // @match *://www.google.tg/*
  180. // @match *://www.google.co.th/*
  181. // @match *://www.google.com.tj/*
  182. // @match *://www.google.tl/*
  183. // @match *://www.google.tm/*
  184. // @match *://www.google.tn/*
  185. // @match *://www.google.to/*
  186. // @match *://www.google.com.tr/*
  187. // @match *://www.google.tt/*
  188. // @match *://www.google.com.tw/*
  189. // @match *://www.google.co.tz/*
  190. // @match *://www.google.com.ua/*
  191. // @match *://www.google.co.ug/*
  192. // @match *://www.google.co.uk/*
  193. // @match *://www.google.com.uy/*
  194. // @match *://www.google.co.uz/*
  195. // @match *://www.google.com.vc/*
  196. // @match *://www.google.co.ve/*
  197. // @match *://www.google.co.vi/*
  198. // @match *://www.google.com.vn/*
  199. // @match *://www.google.vu/*
  200. // @match *://www.google.ws/*
  201. // @match *://www.google.rs/*
  202. // @match *://www.google.co.za/*
  203. // @match *://www.google.co.zm/*
  204. // @match *://www.google.co.zw/*
  205. // @match *://www.google.cat/*
  206. // ==/UserScript==
  207.  
  208. (function() {
  209. 'use strict';
  210. if (/\?q=/.test(location.href)) return;
  211. let LinkPa = document.querySelector("[data-ogbl]");
  212. if (!LinkPa) return;
  213. let bingBgLink = document.createElement("a");
  214. bingBgLink.className = LinkPa.firstChild.firstChild.className;
  215. bingBgLink.target = "_blank";
  216. bingBgLink.innerText = "Bing Bg";
  217. let linkDiv = document.createElement("div");
  218. linkDiv.className = LinkPa.firstChild.className;
  219. linkDiv.appendChild(bingBgLink);
  220. LinkPa.appendChild(linkDiv);
  221. let skinContainer = document.body;
  222. GM_addStyle(`
  223. body{
  224. background-position: center 0;
  225. background-repeat: no-repeat;
  226. background-size: cover;
  227. -webkit-background-size: cover;
  228. -o-background-size: cover;
  229. }
  230. #gb{
  231. background-color: rgb(32 33 36 / 50%)!important;
  232. }
  233. [role="contentinfo"]{
  234. background-color: rgb(32 33 36 / 50%)!important;
  235. }
  236. #gb *,[role="contentinfo"] *{
  237. color: white!important;
  238. }
  239. `);
  240.  
  241. let btnK = document.querySelector("input[name='btnK']");
  242. let clickHandler = e => {
  243. skinContainer.style.backgroundImage = "";
  244. };
  245. btnK.addEventListener("click",clickHandler);
  246. let bingImgObj = GM_getValue("bingImgObj");
  247. if (bingImgObj) {
  248. skinContainer.style.backgroundImage = "url(\"" + bingImgObj.base64 + "\")";
  249. }
  250.  
  251. GM_xmlhttpRequest({
  252. method: 'GET',
  253. url: "https://global.bing.com/HPImageArchive.aspx?format=js&idx=0&pid=hp&video=1&n=1",
  254. onload: function(result) {
  255. let jsonData = null;
  256. try {
  257. jsonData = JSON.parse(result.responseText);
  258. let bgUrl = jsonData.images[0].url;
  259. if (!/^https?:\/\//.test(bgUrl)) {
  260. bgUrl = "https://global.bing.com" + bgUrl;
  261. }
  262. bingBgLink.title = jsonData.images[0].copyright;
  263. bingBgLink.href = bgUrl;
  264. if (bingImgObj && bingImgObj.url == bgUrl) return;
  265. if (!bingImgObj) skinContainer.style.backgroundImage = "url(\"" + bgUrl + "\")";
  266. GM_xmlhttpRequest({
  267. method: 'GET',
  268. url: bgUrl,
  269. responseType: "blob",
  270. onload: function(r) {
  271. let blob = r.response;
  272. let fr = new FileReader();
  273. fr.readAsDataURL(blob);
  274. fr.onload = function (e) {
  275. let base64ImgData = e.target.result;
  276. GM_setValue("bingImgObj",{url: bgUrl, base64: base64ImgData});
  277. };
  278. }
  279. });
  280. } catch (e) {
  281. console.log(e);
  282. }
  283. }
  284. });
  285. })();

QingJ © 2025

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