FocusedWolf

EFT: Subreddit ban message editor

Jul 9th, 2025 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Reddit Ban Editor - EFT Subreddit
  3. // @namespace    https://reddit.com
  4. // @version      2.0
  5. // @description  Tampermonkey script to replace the Reddit ban icon and message on r/EscapefromTarkov
  6. // @author       You
  7. // @match        https://www.reddit.com/r/EscapefromTarkov/*
  8. // @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant        none
  10. // @run-at       document-start
  11. // ==/UserScript==
  12.  
  13. // Turns my tarkov reddit permanent ban message (i said "autist cheaters", the moderator took it personally) into a countdown for WW3.
  14.  
  15. (function(){
  16.     'use strict';
  17.  
  18.     function getDaysUntil(dateStr) {
  19.         const now = new Date();
  20.         const target = new Date(dateStr);
  21.         const diffTime = target - now;
  22.         const diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));
  23.         return diffDays > 0
  24.             ? `${diffDays} day${diffDays !== 1 ? 's' : ''} remaining.`
  25.             : `Welcome to the Rice Fields! ☠`;
  26.     }
  27.  
  28.     function generateMessage() {
  29.         const trumpDeadline = '2025-09-01T12:00:00';
  30.         const xiPutinSummit = '2025-09-02T00:00:00';
  31.         const amphibiousWindow = '2025-09-15T00:00:00';
  32.         const fullDeploymentDate = '2027-12-31T12:00:00'; // German brigade to Lithuania
  33.  
  34.         const message1 = `Trump issues Sept 1 deadline to Russia: ${getDaysUntil(trumpDeadline)}`;
  35.  
  36.         const message2 = `Xi–Putin Beijing summit Sept 2: ${getDaysUntil(xiPutinSummit)}`;
  37.  
  38.         // Why September 15–19 Is Ideal:
  39.         //
  40.         //     It falls just before the new moon (Sept 21) and between spring tide events (Sept 10 and Sept 24), meaning tidal conditions are in a low-to-rising phase, which is favorable for beach approaches.
  41.         //
  42.         //     Nighttime during this window offers minimal moonlight (darkest part of lunar cycle), and the seas are predictable with enhanced tidal height variations—a tactical advantage for stealth and beach access.
  43.         //
  44.         // | Date Range | Lunar Phase                                  | Tidal Status                      | Impact                                     |
  45.         // | ---------- | -------------------------------------------- | --------------------------------- | ------------------------------------------ |
  46.         // | Sept 15–19 | Waxing crescent approaching new moon Sept 21 | Between spring tides (Sept 10–24) | Low-to-rising tides, strong current window |
  47.         // | Sept 21    | New Moon                                     | Maximum spring effect             | Darkest night for stealth                  |
  48.         // | Sept 24    | Post new moon                                | Spring tide peak                  | Reaffirming tidal extremes                 |
  49.         const message3 = `AI says optimal conditions for chinese invasion of Taiwan Sept 15-19: ${getDaysUntil(amphibiousWindow)}`;
  50.  
  51.         const message4 = `German brigade fully deployed by end of 2027: ${getDaysUntil(fullDeploymentDate)}`;
  52.  
  53.         return `► ${message1} ► ${message2} ► ${message3} ► ${message4}`;
  54.     }
  55.  
  56.     function createEmojiIcon(emojiText = '🤠') {
  57.         const emoji = document.createElement('span');
  58.         emoji.textContent = emojiText;
  59.         Object.assign(emoji.style, {
  60.             fontSize: '28px',
  61.             marginRight: '12px',
  62.             lineHeight: '1em',
  63.             display: 'flex',
  64.             alignItems: 'center',
  65.             justifyContent: 'center',
  66.             height: '100%',
  67.         });
  68.         return emoji;
  69.     }
  70.  
  71.     function patchBanBanner() {
  72.         const banner = document.querySelector('div[slot="post-banned-banner"]');
  73.         if (!banner) return false;
  74.  
  75.         let patched = false;
  76.  
  77.         // Replace icon if not already replaced
  78.         const icon = banner.querySelector('svg[icon-name^="ban"]');
  79.         if (icon) {
  80.             icon.replaceWith(createEmojiIcon());
  81.             patched = true;
  82.         }
  83.  
  84.         const msg = banner.querySelector('span.flex-auto');
  85.         const newText = generateMessage();
  86.         if (msg && msg.textContent.trim() !== newText) {
  87.             msg.textContent = newText;
  88.             patched = true;
  89.         }
  90.  
  91.         return patched;
  92.     }
  93.  
  94.     function observeOnceBannerExists() {
  95.         const tryInterval = setInterval(() => {
  96.             const banner = document.querySelector('div[slot="post-banned-banner"]');
  97.             if (banner) {
  98.                 clearInterval(tryInterval);
  99.                 patchBanBanner();
  100.  
  101.                 const observer = new MutationObserver(() => {
  102.                     try {
  103.                         patchBanBanner();
  104.                     } catch (e) {
  105.                         console.warn('Reddit Ban Editor error:', e);
  106.                     }
  107.                 });
  108.                 observer.observe(document.body, { childList: true, subtree: true });
  109.             }
  110.         }, 250);
  111.     }
  112.  
  113.     function setupSPAWatches() {
  114.         const originalPushState = history.pushState;
  115.         const originalReplaceState = history.replaceState;
  116.  
  117.         function triggerPatch() {
  118.             setTimeout(() => {
  119.                 observeOnceBannerExists();
  120.                 patchBanBanner();
  121.             }, 200);
  122.         }
  123.  
  124.         history.pushState = function (...args) {
  125.             originalPushState.apply(this, args);
  126.             triggerPatch();
  127.         };
  128.  
  129.         history.replaceState = function (...args) {
  130.             originalReplaceState.apply(this, args);
  131.             triggerPatch();
  132.         };
  133.  
  134.         window.addEventListener('popstate', triggerPatch);
  135.     }
  136.  
  137.     setupSPAWatches();
  138.     observeOnceBannerExists();
  139.  
  140.     // Periodic update every hour to keep countdown fresh
  141.     setInterval(patchBanBanner, 60 * 60 * 1000);
  142. })();
  143.  
Add Comment
Please, Sign In to add comment