luogu-background-css-loader

洛谷主题背景修改

  1. // ==UserScript==
  2. // @name luogu-background-css-loader
  3. // @namespace luogu-background-css-loader
  4. // @version 1.0
  5. // @description 洛谷主题背景修改
  6. // @author Zhetengtiao
  7. // @match *://www.luogu.com.cn/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @grant GM_registerMenuCommand
  11. // ==/UserScript==
  12.  
  13. function payload()
  14. {
  15. var css = GM_getValue("css");
  16. document.querySelector('main[style="background-color: rgb(239, 239, 239);"]').style=css;//新版原生方法
  17. }
  18. window.onload=function(){
  19. var config = GM_getValue("config");
  20. if(GM_getValue("config")==null) {
  21. config=1
  22. alert("感谢使用!第一次运行请打开Tampermonkey菜单,点击“设置背景CSS”以设置背景CSS");
  23. GM_setValue("config",config);
  24. GM_setValue("css","background-color: rgb(239, 239, 239);");
  25. }
  26. GM_registerMenuCommand("设置背景CSS",function(){
  27. var css = GM_getValue("css");
  28. css=prompt("设置背景CSS:","");
  29. GM_setValue("css",css);
  30. alert("设置成功!请刷新页面");
  31. });
  32. payload();//页面加载完毕运行一次
  33. setTimeout(function(){
  34. payload();
  35. }, 2000);//运行后2秒后再运行一次
  36. };