Google调用bing壁纸

google搜索时随机使用bing壁纸,参考:https://gf.qytechs.cn/zh-CN/scripts/25202-%E7%99%BEbing%E5%9B%BE

  1. // ==UserScript==
  2. // @name Google调用bing壁纸
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description google搜索时随机使用bing壁纸,参考:https://gf.qytechs.cn/zh-CN/scripts/25202-%E7%99%BEbing%E5%9B%BE
  6. // @author darkz
  7. // @grant GM_xmlhttpRequest
  8. // @grant GM_log
  9. // @grant unsafeWindow
  10. // @connect global.bing.com
  11. // @connect www.bing.com
  12. // @connect cn.bing.com
  13. // @include *://www.google.com/
  14. // @include *://www.google.com.hk/
  15. // @exclude /^https?://www\.google\.com(\.[a-z]+)/.*search?q=.+/
  16. // @exclude /^https?://www\.google\.com(\.[a-z]+)/.*&q=.+/
  17. // @exclude /^https?://www\.google\.com\.hk/.*&q=.+/
  18. // @exclude /^https?://www.google.com/#newwindow=1&q=
  19. // @exclude /^https?://www.google.com.hk/#newwindow=1&q=
  20.  
  21. // ==/UserScript==
  22.  
  23. (function() {
  24. 'use strict';
  25. //GM_log('就是测试下输出呀,需要提前在前面增加grant');
  26. // Your code here...
  27. var idx=Math.floor(Math.random()*5);
  28. var url="http://www.bing.com/HPImageArchive.aspx?format=js&idx="+idx+"&n=1&mkt=en-US";
  29. GM_log('随机壁纸');
  30.  
  31. GM_xmlhttpRequest({
  32.  
  33. method: "GET",
  34. url: url,
  35. onload: function(response) {
  36.  
  37. GM_log('bing bg idx is ' +idx);
  38. var jsonData = null;
  39. try {
  40. jsonData = JSON.parse(response.responseText);
  41. var bgUrl=jsonData.images[0].url;
  42. if(!/^https?:\/\//.test(bgUrl)){
  43. bgUrl="http://cn.bing.com"+bgUrl;
  44. }
  45. GM_log('bing bg image url is ' +bgUrl);
  46. var newHTML = document.createElement ('div');
  47. newHTML.innerHTML = '<div id="cpBackgroundDiv" style="position: fixed;top: 0%;left: 0%; width: 100%;height: 100%;z-index: -1; visibility: visible;"><img id="cpBackgroundImg" src="'+bgUrl+'" style="width: 100%;height: 100%;"></div>';
  48. document.body.appendChild (newHTML);
  49.  
  50. }catch (e) {
  51. console.log(e);
  52. }
  53.  
  54. }
  55. });
  56.  
  57. })();

QingJ © 2025

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