Greasy Fork镜像 支持简体中文。

April Fools Ads - grundos.cafe

Restores the ads from the 2024 april fools prank

  1. // ==UserScript==
  2. // @name April Fools Ads - grundos.cafe
  3. // @namespace Firestix
  4. // @match https://www.grundos.cafe/*
  5. // @grant GM_log
  6. // @grant GM_addStyle
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_unregisterMenuCommand
  11. // @version 1.0.1
  12. // @author Firestix
  13. // @license MIT
  14. // @run-at document-start
  15. // @description Restores the ads from the 2024 april fools prank
  16. // ==/UserScript==
  17.  
  18. GM_addStyle(`
  19. #advert-header{
  20. height: 93px;
  21. }
  22. `);
  23.  
  24. function registerAutoRefreshCommand(enabled) {
  25. GM_unregisterMenuCommand(`${enabled ? "Enable" : "Disable"} Ads`);
  26. GM_registerMenuCommand(`${enabled ? "Disable" : "Enable"} Ads`,()=>{
  27. GM_setValue("GCAdEnable", !enabled);
  28. registerAutoRefreshCommand(!enabled);
  29. });
  30. }
  31.  
  32. registerAutoRefreshCommand(GM_getValue("GCAdEnable", true));
  33.  
  34. GM_registerMenuCommand("Force Refresh Ad Database",()=>{
  35. if (confirm("Are you sure you want to refresh the label database?")) {
  36. GM_setValue("GCAdListForceRefresh",true);
  37. }
  38. });
  39. (async function () {
  40. if (!GM_getValue("GCAdEnable", true)) return;
  41. let databaseList = GM_getValue("GCAdDatabaseList", false);
  42. if (!databaseList) {
  43. databaseList = "https://pastebin.com/raw/5egym4tE";
  44. GM_setValue("GCAdDatabaseList",databaseList);
  45. }
  46. let json = GM_getValue("GCAdList", false);
  47. if (!json || GM_getValue("GCAdListForceRefresh", true)) {
  48. if(!json) {
  49. json = [];
  50. GM_log("Initializing ad list database (this should only happen once)");
  51. }
  52. GM_log(`Fetching data from ${databaseList}`);
  53. json = await fetch(databaseList,{cache: "no-store"}).then(res=>res.json());
  54. GM_log(`Found ${json.length} items(s)`);
  55. GM_setValue("GCAdList",json);
  56. GM_setValue("GCAdListForceRefresh",false);
  57. }
  58. let adData = json[Math.floor(Math.random()*json.length)];
  59.  
  60. let adHeader = document.createElement("div");
  61. adHeader.id = "advert-header";
  62. let adImg = document.createElement("img");
  63. adImg.src = `https://grundoscafe.b-cdn.net/bannerads${adData.advert.img}`;
  64. let adLink = document.createElement("a");
  65. adLink.href = `http://www.grundos.cafe${adData.advert.url}`;
  66. adLink.appendChild(adImg);
  67. adHeader.appendChild(adLink);
  68. new MutationObserver(function() {
  69. let elem = document.getElementsByTagName('div')[0];
  70. if (elem && elem.id == "container") {
  71. elem.appendChild(adHeader);
  72. this.disconnect();
  73. }
  74. }).observe(document, {childList: true, subtree: true});
  75. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址