GreasyFork - 在“代码”中显示 jQuery 警告

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

目前为 2020-10-11 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name GreasyFork - jQuery Warning in the Code Tab
  3. // @name:zh-CN GreasyFork - 在“代码”中显示 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. // @author RainSlide
  8. // @icon https://greasyfork.org/assets/blacklogo96-1221dbbb8f0d47a728f968c35c2e2e03c64276a585b8dceb7a79a17a3f350e8a.png
  9. // @version 1.1
  10. // @match https://greasyfork.org/*/scripts/*/code
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. "use strict";
  15.  
  16. (() => {
  17. const pre = document.querySelector('#script-content > pre');
  18. if (
  19. pre !== null &&
  20. /\n[ \t]*\/\/[ \t]*@require[ \t]+.+?jquery/.test(pre.textContent)
  21. ) pre.parentNode.insertBefore(
  22. (() => {
  23. const p = document.createElement("p");
  24. const strong = document.createElement("strong");
  25. p.style = "text-align: center;"
  26. strong.textContent = "jQuery!!!";
  27. strong.style = "color: red; font-size: 5em;";
  28. p.appendChild(strong);
  29. return p;
  30. })(), pre
  31. );
  32. })();