在“代码”中显示 jQuery 警告

在查看 Greasy Fork 代码页时,通过判断 @require 行中是否有 jquery,显示特大号红色 jQuery 警告。

当前为 2019-11-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name jQuery Warning in the Code Tab
  3. // @name:zh-CN 在“代码”中显示 jQuery 警告
  4. // @description Match "jquery" in @require lines and show large jQuery warning when you are checking out the Code tab on Greasy Fork.
  5. // @description:zh-CN 在查看 Greasy Fork 代码页时,通过判断 @require 行中是否有 jquery,显示特大号红色 jQuery 警告。
  6. // @namespace RainSlide
  7. // @match https://greasyfork.org/*/scripts/*/code
  8. // @version 1.0
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. if ( document.querySelector('#script-content > pre') ) {
  13. const pre = document.querySelector('#script-content > pre');
  14. if (
  15. /\n[ \t]*\/\/[ \t]*@require[ \t]+.+?jquery/.test(pre.textContent)
  16. ) pre.parentNode.insertBefore(
  17. (() => {
  18. const p = document.createElement("p"),
  19. strong = document.createElement("strong");
  20. strong.textContent = "jQuery!!!";
  21. p.style = "text-align: center;"
  22. strong.style = "color: red; font-size: 5em;";
  23. p.appendChild(strong);
  24. return p;
  25. })(), pre
  26. );
  27. }