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

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

目前为 2021-04-03 提交的版本。查看 最新版本

  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/packs/media/images/blacklogo96-b2384000fca45aa17e45eb417cbcbb59.png
  9. // @version 1.2
  10. // @match https://greasyfork.org/*/scripts/*/code
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. "use strict";
  15.  
  16. (() => {
  17. const container = document.querySelector('.code-container');
  18. if (container !== null) {
  19. const pre = container.querySelector(':scope > pre');
  20. pre !== null &&
  21. /\n[ \t]*\/\/[ \t]*@require[ \t]+.+?jquery/.test(pre.textContent) &&
  22. container.parentNode.insertBefore(
  23. (() => {
  24. const p = document.createElement("p");
  25. const strong = document.createElement("strong");
  26. p.style = "text-align: center;"
  27. strong.textContent = "jQuery!!!";
  28. strong.style = "color: red; font-size: 5em;";
  29. p.appendChild(strong);
  30. return p;
  31. })(), container
  32. );
  33. }
  34. })();