在“代码”中显示 jQuery 警告

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

当前为 2020-02-14 提交的版本,查看 最新版本

  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. // @author RainSlide
  7. // @namespace RainSlide
  8. // @match https://greasyfork.org/*/scripts/*/code
  9. // @version 1.0
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. if ( document.querySelector('#script-content > pre') ) {
  14. const pre = document.querySelector('#script-content > pre');
  15. if (
  16. /\n[ \t]*\/\/[ \t]*@require[ \t]+.+?jquery/.test(pre.textContent)
  17. ) pre.parentNode.insertBefore(
  18. (() => {
  19. const p = document.createElement("p");
  20. const strong = document.createElement("strong");
  21. p.style = "text-align: center;"
  22. strong.textContent = "jQuery!!!";
  23. strong.style = "color: red; font-size: 5em;";
  24. p.appendChild(strong);
  25. return p;
  26. })(), pre
  27. );
  28. }