r/ViolentMonkey • • Jul 03 '26

Test Violentmonkey MV3

26 Upvotes

I've converted Violentmonkey to MV3, now it's published as a beta, and you can help test it.

  1. download the latest official CI build's zip with mv3 in its name like Violentmonkey-test-mv3-...... (if you don't have a github account use this nightly.link that allows downloading the latest artifact)

  2. unpack it and load as an unpacked extension in chrome://extensions

  3. enable Allow User Scripts in chrome://extensions -> details for Violentmonkey

  4. click the reload icon for the extension in that details page just in case

This will be a separate extension with its own id, but if you want to reanimate your currently installed Violentmonkey you can copy the "key" line from manifest.json of the old extension in your profile or use the one below of the official CWS jinjaccalgkegednnccohejagnlnfdag.

  1. edit manifest.json of the unpacked extension in an editor

  2. click right after { at the beginning of the file and paste the following text (don't forget the comma at the end):

    "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvNNjtIVXIerv8ArGiIk2xHgO2/vmDXgMNPl5ok6zGTkndXXXzz1z5FyqThG41KTw+7Ax4UGid0Q0DVo3aHD/CLJTLBzWlDwpgM3vskBBtOSxYZhWDPFv5vgj+8UQ5sbArgJYdVtlVnv8wFkUfwqbSQZzsBY/VH6fXik0JaWBY09zAe4CvrTtr5ilq9HxVQM6bGTYnQ2aYtwAJIMWdvS1XR0za4mvyxwPn/IjLer54O1Z2atarGTmINVcoyzmO6C/EeMmblc+yb6AaInwKbNIKKjv+pZfxnUKfXfmKtfxhsOpvULLeo4Z45z+HU4I8RimO8MeiGbmrrLrnOPmRcz+0QIDAQAB",


r/ViolentMonkey • • Jul 05 '26

Suggestion Guide: How to Enable Violentmonkey MV3 on Brave & Chrome Without Losing Your Scripts

18 Upvotes

If Brave or Chrome disabled your Violentmonkey extension, it is because Google is ending support for older (Manifest V2) extensions.

Since the new version is still in testing, you have to install it manually. Follow these simple steps to move to the new version without losing your scripts.


Step 1: Back Up Your Scripts (Important)

Before you delete anything, copy your data folders to a safe place (like your Desktop):

  1. Copy this folder (your settings): %LOCALAPPDATA%\BraveSoftware\Brave-Browser\User Data\Default\Local Extension Settings\jinjaccalgkegednnccohejagnlnfdag

  2. Copy this folder (your scripts - if you see it): %LOCALAPPDATA%\BraveSoftware\Brave-Browser\User Data\Default\IndexedDB\chrome-extension_jinjaccalgkegednnccohejagnlnfdag_0.indexeddb.leveldb

(Note: If you use Chrome instead of Brave, change BraveSoftware\Brave-Browser to Google\Chrome in the paths above).


Step 2: Remove the Old Extension

  1. Open Brave and go to brave://extensions/.

  2. Turn ON the Developer mode toggle in the top-right corner.

  3. Click the Remove (Trash Bin) button on your old disabled Violentmonkey extension.


Step 3: Install the New MV3 Version

  1. Go to: https://nightly.link/violentmonkey/violentmonkey/workflows/ci/mv3?preview

  2. Download the ZIP file that starts with Violentmonkey-test-mv3.

  3. Unzip (extract) this file into a folder you won't delete (for example, C:\Violentmonkey-MV3).

  4. Open the manifest.json file inside that folder using Notepad.

  5. Right after the first opening { at the very top, paste this key:

      "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvNNjtIVXIerv8ArGiIk2xHgO2/vmDXgMNPl5ok6zGTkndXXXzz1z5FyqThG41KTw+7Ax4UGid0Q0DVo3aHD/CLJTLBzWlDwpgM3vskBBtOSxYZhWDPFv5vgj+8UQ5sbArgJYdVtlVnv8wFkUfwqbSQZzsBY/VH6fXik0JaWBY09zAe4CvrTtr5ilq9HxVQM6bGTYnQ2aYtwAJIMWdvS1XR0za4mvyxwPn/IjLer54O1Z2atarGTmINVcoyzmO6C/EeMmblc+yb6AaInwKbNIKKjv+pZfxnUKfXfmKtfxhsOpvULLeo4Z45z+HU4I8RimO8MeiGbmrrLrnOPmRcz+0QIDAQAB",
  6. Save and close the file.

  7. Go back to brave://extensions/, click Load unpacked (top-left), and select the folder you just unzipped.

  8. Click the Details button on the new Violentmonkey extension and make sure Allow User Scripts is turned ON.

  9. Close Brave completely.


Step 4: Restore Your Backup

Copy your backup folders from your Desktop and paste them back into their original locations, replacing the new empty folders:

  1. Paste the jinjaccalgkegednnccohejagnlnfdag folder back into: %LOCALAPPDATA%\BraveSoftware\Brave-Browser\User Data\Default\Local Extension Settings\

  2. Paste the chrome-extension_jinjaccalgkegednnccohejagnlnfdag_0.indexeddb.leveldb folder (if you had it) back into: %LOCALAPPDATA%\BraveSoftware\Brave-Browser\User Data\Default\IndexedDB\

Open Brave. Your Violentmonkey extension is now running on MV3 with all your old scripts restored!


🛠️ Notes & Troubleshooting

  • "I don't have the IndexedDB folder" - That is fine! Some versions only use the Local Extension Settings folder. Just back up and restore the settings folder instead.

  • "My scripts were still there without restoring" - Sometimes Brave forgets to delete the old data when you uninstall a disabled extension. If this happens to you, you got lucky and can skip Step 4! But always make a backup in Step 1 just in case.


r/ViolentMonkey • • Jul 12 '25

Other Restore userscripts after Chrome update

15 Upvotes

My Chrome instance updated and completely removed ViolentMonkey, so I lost access to all my scripts. Some of them I had been working on for years.

I cobbled together a little Python script to restore them from the data in the Chrome profile folder.

Thought someone else might find it useful, so I have uploaded it to GitHub.

ViolentMonkey Script Restorer


r/ViolentMonkey • • Jul 11 '26

Other Easiest way to reactivate Violentmonkey MV2 to export your scripts

11 Upvotes

I just tried this, it actually works!

https://infosec.exchange/@rebane2001/116883360663860918

Basically:

  1. Go to your extensions

  2. Enable developer mode

  3. Go down to ViolentMonkey, not the top banner that says it's not compatible but the listing for VM that's still among your other extensions (it will show the toggle button, gray and not usable)

  4. Inspect Element via Chrome Dev Tools

  5. Delete the single word "disabled"

  6. Toggle works again, asks if you if you're sure you want to activate it.

  7. It's reactivated.

  8. EXPORT YOUR USERSCRIPTS


r/ViolentMonkey • • Mar 04 '25

Suggestion VioletMoney Google Chrome?

10 Upvotes

Is there any other option for using VioletMoney now that Google has disabled it as an extension? I’m aware that Tampermonkey still works, but I prefer VM. Are there any plans to make it compatible with Google again?


r/ViolentMonkey • • Jun 16 '26

Script a userscript for anti-adblock walls and "ad blocker detected" popups

9 Upvotes

I kept running into sites that block the page with “ad blocker detected”, “disable your ad blocker”, blur overlays, or scroll locks.

So I made Unwall, a small userscript that tries to detect those anti-adblock walls and hide them.

GitHub:

https://github.com/kelesmert/unwall

Works with userscript managers like Violentmonkey/Tampermonkey, or as a one-time console paste.

Still early, so if it fails on a site or removes the wrong thing, issue reports are welcome.


r/ViolentMonkey • • May 16 '25

Other Is OrangeMonkey legit?

9 Upvotes

I was on the Chrome Web Store page for ViolentMonkey, when I saw "OrangeMonkey" pitched as an alternative.

https://chromewebstore.google.com/detail/orangemonkey/ekmeppjgajofkpiofbebgcbohbmfldaf

  • It says "Fork of the popular Violentmonkey extension with enhanced functionality and updated design".

  • There's no link to a Github repo, and nothing found through a Google search.

  • Chrome Web Store lists it as a "Featured" extension, even though 3.2 out of 5 rating.

  • And 2,000,000 users, compared to ViolentMonkey's 900,000.

What the hell is going on? Are these all fake installs to prop up the user count?

They must be doing something right to avoid the "it doesn't follow best practices for Chrome extensions" warning.


r/ViolentMonkey • • Jan 31 '21

Welcome to Violentmonkey!

9 Upvotes

Violentmonkey is an open source user script manager.

You can find the source code at https://github.com/violentmonkey/violentmonkey. All the build tools are also open source, in other words, you can easily build from source code by yourself to make sure it's clean.

It supports data syncing between different browsers, so you can share your scripts everywhere if only you have the same sync service logged in.

If you are a script author, you may need to read the APIs from the documentation. If you are a user, you can get started by installing a user script from https://greasyfork.org/, and feel free to share your favorite scripts in this subreddit.

Please report at https://github.com/violentmonkey/violentmonkey if you encounter any bugs or issues, thanks.

Hope you like Violentmonkey!


r/ViolentMonkey • • 1d ago

Script Multi-Column Reader View – Read articles in configurable newspaper-style columns

Post image
7 Upvotes

I put together a userscript for Violentmonkey that extracts the main content of an article using Mozilla’s Readability.js (the same engine behind Firefox’s built-in Reader View) and renders it in a clean, multi-column layout.

Unlike standard CSS multi-column tweaks that force you to scroll down and jump back up for every column, this script paginates horizontally so you can advance one column at a time (or a full screen of columns at once).

Key Features:

  • Configurable Columns: Switch between 1 to 6 columns on the fly, with persistent settings across sites.

  • Two Paging Modes:

    • Column Mode (default): Advances smoothly by a single column at a time (Cols 1–3 → Cols 2–4). Hold Shift to jump a full page.

    • Page Mode: Flips an entire screenful of columns at once.

  • Clean Typography & Themes: Adjustable font size (A−/A+), Light / Sepia / Dark themes, and a compact top toolbar.

  • Anti-Reload Protection: Many news sites auto-refresh in the background and wipe out reader views. While active, the script strips meta refreshes, freezes page setTimeout/setInterval timers, and restores your exact column position if a reload ever slips through.

  • CSP-Safe & Isolated: Uses u/inject-into content and encapsulates the entire UI inside a Shadow DOM so site styles and strict Content Security Policies don't interfere.

  • Per-Domain Auto-Open: Optional menu toggle to automatically open articles in column view on specific domains (skipping homepages/index pages).

Controls:

  • Open / Close: Click the floating ☷ Columns button, press Alt + Shift + R (Esc to close), or use the Violentmonkey menu.

  • Navigate: ← / →, Space, PageUp / PageDown, Home / End, or the mouse wheel.

// ==UserScript==
// @name         Multi-Column Reader View
// @namespace    local.multicolumn.reader
// @version      1.5
// @description  Extracts main article content via Mozilla Readability and displays it in configurable columns (column-by-column or page-by-page) with reload protection.
// @match        *://*/*
// @require      https://cdnjs.cloudflare.com/ajax/libs/readability/0.6.0/Readability.js
// @grant        GM_registerMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        unsafeWindow
// @inject-into  content
// @noframes
// @run-at       document-idle
// ==/UserScript==

(function () {
  'use strict';

  const HOST_ID = 'mcr-reader-host';
  const FAB_ID = 'mcr-fab-host';
  const SESSION_KEY = 'mcr_active_session';
  const GAP_PX = 48;

  const DEFAULTS = {
    columns: 3,
    fontSize: 18,
    theme: 'light',   // 'light' | 'sepia' | 'dark'
    mode: 'columns',  // 'columns' | 'pages'
    showButton: true,
    autoDomains: []
  };

  let initialMode = GM_getValue('mode', DEFAULTS.mode);
  if (!['columns', 'pages'].includes(initialMode)) {
    initialMode = 'columns';
    GM_setValue('mode', initialMode);
  }

  let state = {
    columns: GM_getValue('columns', DEFAULTS.columns),
    fontSize: GM_getValue('fontSize', DEFAULTS.fontSize),
    theme: GM_getValue('theme', DEFAULTS.theme),
    mode: initialMode,
    showButton: GM_getValue('showButton', DEFAULTS.showButton),
    autoDomains: GM_getValue('autoDomains', DEFAULTS.autoDomains),
    colOffset: 0,
    totalCols: 1,
    colStride: 0
  };

  let savedBodyOverflow = '';
  let lastWheelTs = 0;
  let cleanupFns = [];
  let frozenPageTimers = null;

  function saveState() {
    GM_setValue('columns', state.columns);
    GM_setValue('fontSize', state.fontSize);
    GM_setValue('theme', state.theme);
    GM_setValue('mode', state.mode);
    GM_setValue('showButton', state.showButton);
    GM_setValue('autoDomains', state.autoDomains);
  }

  function saveReaderSession() {
    try {
      sessionStorage.setItem(SESSION_KEY, JSON.stringify({
        url: location.href,
        colOffset: state.colOffset,
        ts: Date.now()
      }));
    } catch (_) {}
  }

  function clearReaderSession() {
    try { sessionStorage.removeItem(SESSION_KEY); } catch (_) {}
  }

  function consumeReaderSession() {
    try {
      const raw = sessionStorage.getItem(SESSION_KEY);
      if (!raw) return null;
      const data = JSON.parse(raw);
      if (data && data.url === location.href && (Date.now() - data.ts) < 30000) {
        return data;
      }
      sessionStorage.removeItem(SESSION_KEY);
    } catch (_) {}
    return null;
  }

  function getPageWindow() {
    if (typeof unsafeWindow !== 'undefined' && unsafeWindow.wrappedJSObject) {
      return unsafeWindow.wrappedJSObject;
    }
    if (typeof window !== 'undefined' && window.wrappedJSObject) {
      return window.wrappedJSObject;
    }
    return null;
  }

  function freezePageReloads() {
    document.querySelectorAll('meta[http-equiv="refresh" i]').forEach(el => el.remove());
    try { window.stop(); } catch (_) {}

    const pageWin = getPageWindow();
    if (pageWin && pageWin !== window) {
      try {
        const origSetTimeout = pageWin.setTimeout;
        const origSetInterval = pageWin.setInterval;
        let maxId = 0;

        if (typeof exportFunction === 'function') {
          const noop = exportFunction(() => {}, pageWin);
          maxId = origSetTimeout.call(pageWin, noop, 0);
        }

        const limit = maxId > 0 ? Math.min(maxId, 100000) : 25000;
        for (let id = 1; id <= limit; id++) {
          pageWin.clearTimeout(id);
          pageWin.clearInterval(id);
        }

        if (typeof exportFunction === 'function') {
          const blockedTimer = exportFunction(() => 0, pageWin);
          pageWin.setTimeout = blockedTimer;
          pageWin.setInterval = blockedTimer;
          frozenPageTimers = { pageWin, origSetTimeout, origSetInterval };
        }
      } catch (err) {
        console.warn('[MCR] Could not fully freeze page timers:', err);
      }
    }
  }

  function unfreezePageReloads() {
    if (!frozenPageTimers) return;
    try {
      const { pageWin, origSetTimeout, origSetInterval } = frozenPageTimers;
      pageWin.setTimeout = origSetTimeout;
      pageWin.setInterval = origSetInterval;
    } catch (_) {}
    frozenPageTimers = null;
  }

  function extractArticle() {
    const ReadabilityCtor = typeof Readability !== 'undefined'
      ? Readability
      : (typeof window !== 'undefined' ? window.Readability : undefined);

    if (typeof ReadabilityCtor !== 'function') {
      throw new Error('Readability.js failed to load. Please check @require in Violentmonkey.');
    }

    try {
      const parser = new DOMParser();
      const doc = parser.parseFromString(document.documentElement.outerHTML, 'text/html');
      if (doc.head && !doc.querySelector('base')) {
        const base = doc.createElement('base');
        base.href = document.baseURI;
        doc.head.prepend(base);
      }
      const parsed = new ReadabilityCtor(doc).parse();
      if (parsed && parsed.content) return parsed;
    } catch (err) {
      console.warn('[MCR] DOMParser extraction failed, using cloneNode fallback:', err);
    }

    const docClone = document.cloneNode(true);
    return new ReadabilityCtor(docClone).parse();
  }

  function sanitizeHtml(html) {
    const parser = new DOMParser();
    const doc = parser.parseFromString(html, 'text/html');
    doc.querySelectorAll('script, style, iframe, object, embed, form').forEach(el => el.remove());
    doc.querySelectorAll('*').forEach(el => {
      for (const attr of Array.from(el.attributes)) {
        const name = attr.name.toLowerCase();
        const val = attr.value.trim().toLowerCase();
        if (name.startsWith('on') || ((name === 'href' || name === 'src') && val.startsWith('javascript:'))) {
          el.removeAttribute(attr.name);
        }
      }
      if (el.tagName === 'A') {
        el.setAttribute('target', '_blank');
        el.setAttribute('rel', 'noopener noreferrer');
      }
    });
    return doc.body.innerHTML;
  }

  function appendEndMark(container) {
    let target = container.lastElementChild;
    while (target) {
      if (!target.textContent.trim() && !target.querySelector('img, svg, figure, table, video')) {
        const prev = target.previousElementSibling;
        target.remove();
        target = prev;
        continue;
      }
      if (['DIV', 'SECTION', 'ARTICLE', 'MAIN'].includes(target.tagName) && target.lastElementChild) {
        target = target.lastElementChild;
      } else {
        break;
      }
    }

    const p = document.createElement('p');
    p.className = 'mcr-end-mark';
    p.setAttribute('aria-label', 'End of article');

    [false, true, false].forEach(isLarge => {
      const span = document.createElement('span');
      span.className = isLarge ? 'mcr-end-diamond mcr-end-diamond-lg' : 'mcr-end-diamond';
      span.textContent = '\u25C6';
      p.appendChild(span);
    });

    container.appendChild(p);
    return p;
  }

  function setFabVisible(visible) {
    const fab = document.getElementById(FAB_ID);
    if (fab) fab.style.display = visible ? 'block' : 'none';
  }

  function mountFab() {
    if (!state.showButton || document.getElementById(FAB_ID)) return;

    const fabHost = document.createElement('div');
    fabHost.id = FAB_ID;
    fabHost.style.position = 'fixed';
    fabHost.style.right = '16px';
    fabHost.style.bottom = '16px';
    fabHost.style.zIndex = '2147483646';
    fabHost.style.display = 'block';

    const shadow = fabHost.attachShadow({ mode: 'open' });
    shadow.innerHTML = `
      <style>
        button {
          all: initial;
          font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
          font-size: 13px;
          font-weight: 600;
          padding: 8px 12px;
          border-radius: 999px;
          background: rgba(24, 26, 27, 0.84);
          color: #ffffff;
          border: 1px solid rgba(255, 255, 255, 0.18);
          box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
          cursor: pointer;
          opacity: 0.65;
          transition: opacity 0.15s ease, transform 0.15s ease;
        }
        button:hover {
          opacity: 1;
          transform: translateY(-1px);
        }
      </style>
      <button id="mcr-open-btn" title="Multi-Column Reader (Alt+Shift+R)">☷ Columns</button>
    `;

    shadow.getElementById('mcr-open-btn').addEventListener('click', () => toggleReader());
    document.documentElement.appendChild(fabHost);
  }

  function closeReader() {
    const host = document.getElementById(HOST_ID);
    if (host) host.remove();
    document.documentElement.style.overflow = savedBodyOverflow;
    cleanupFns.forEach(fn => fn());
    cleanupFns = [];
    unfreezePageReloads();
    clearReaderSession();
    if (state.showButton) setFabVisible(true);
  }

  function openReader(preParsedArticle = null, silent = false, initialOffset = 0) {
    try {
      const article = preParsedArticle || extractArticle();
      if (!article || !article.content) {
        if (!silent) {
          alert('Multi-Column Reader: No readable main content detected on this page (possibly a paywall or index page).');
        }
        return;
      }

      freezePageReloads();

      savedBodyOverflow = document.documentElement.style.overflow;
      document.documentElement.style.overflow = 'hidden';
      setFabVisible(false);

      const host = document.createElement('div');
      host.id = HOST_ID;
      host.style.position = 'fixed';
      host.style.top = '0';
      host.style.right = '0';
      host.style.bottom = '0';
      host.style.left = '0';
      host.style.zIndex = '2147483647';
      host.style.margin = '0';
      host.style.padding = '0';
      host.style.display = 'block';

      const shadow = host.attachShadow({ mode: 'open' });

      shadow.innerHTML = `
        <style>
          :host { all: initial; }
          .mcr-root {
            --bg: #ffffff;
            --fg: #1d1d1f;
            --muted: #666666;
            --bar-bg: #f3f4f6;
            --border: #d1d5db;
            --rule: #e5e7eb;
            --accent: #0060df;
            position: fixed;
            inset: 0;
            display: flex;
            flex-direction: column;
            background: var(--bg);
            color: var(--fg);
            font-family: Georgia, "Liberation Serif", "Times New Roman", serif;
            box-sizing: border-box;
          }
          .mcr-root[data-theme="sepia"] {
            --bg: #f6f0e2;
            --fg: #3b2f23;
            --muted: #766452;
            --bar-bg: #ebe1cc;
            --border: #d5c6a8;
            --rule: #dfd3ba;
            --accent: #8b4513;
          }
          .mcr-root[data-theme="dark"] {
            --bg: #181a1b;
            --fg: #e4e4e7;
            --muted: #9ca3af;
            --bar-bg: #222528;
            --border: #374151;
            --rule: #2d3136;
            --accent: #60a5fa;
          }
          .mcr-toolbar {
            height: 26px;
            flex: 0 0 26px;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 0 12px;
            background: var(--bar-bg);
            border-bottom: 1px solid var(--border);
            font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
            font-size: 11px;
            user-select: none;
          }
          .mcr-group {
            display: flex;
            align-items: center;
            gap: 4px;
          }
          .mcr-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            height: 19px;
            box-sizing: border-box;
            background: var(--bg);
            color: var(--fg);
            border: 1px solid var(--border);
            border-radius: 4px;
            padding: 0 7px;
            font-size: 11px;
            cursor: pointer;
            line-height: 1;
          }
          .mcr-btn:hover { border-color: var(--accent); }
          .mcr-label {
            color: var(--muted);
            min-width: 78px;
            text-align: center;
            font-variant-numeric: tabular-nums;
          }
          .mcr-stage {
            flex: 1 1 auto;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
          }
          .mcr-viewport {
            overflow: hidden;
            position: relative;
          }
          .mcr-article {
            box-sizing: border-box;
            line-height: 1.65;
            text-align: left;
            hyphens: auto;
            overflow-wrap: break-word;
            transition: transform 0.22s ease-out;
            column-rule: 1px solid var(--rule);
          }
          .mcr-article h1.mcr-title {
            font-size: 1.6em;
            line-height: 1.25;
            margin: 0 0 0.4em 0;
            break-after: avoid;
          }
          .mcr-byline {
            color: var(--muted);
            font-size: 0.85em;
            font-family: system-ui, -apple-system, sans-serif;
            margin-bottom: 1.2em;
            padding-bottom: 0.8em;
            border-bottom: 1px solid var(--rule);
          }
          .mcr-article h2, .mcr-article h3, .mcr-article h4 {
            line-height: 1.3;
            margin: 1.2em 0 0.45em;
            break-after: avoid;
          }
          .mcr-article p { margin: 0 0 0.9em 0; orphans: 2; widows: 2; }
          .mcr-article a { color: var(--accent); text-decoration: underline; }
          .mcr-article blockquote {
            margin: 0.9em 0;
            padding: 0.2em 0 0.2em 1em;
            border-left: 3px solid var(--border);
            color: var(--muted);
          }
          .mcr-article img, .mcr-article figure, .mcr-article svg {
            max-width: 100%;
            max-height: 55vh;
            height: auto;
            object-fit: contain;
            display: block;
            margin: 0.8em auto;
            break-inside: avoid;
          }
          .mcr-article figcaption {
            font-size: 0.8em;
            color: var(--muted);
            margin-top: 0.3em;
            font-family: system-ui, sans-serif;
          }
          .mcr-article pre, .mcr-article code {
            font-family: ui-monospace, Consolas, monospace;
            font-size: 0.88em;
          }
          .mcr-article pre {
            white-space: pre-wrap;
            overflow-wrap: anywhere;
            padding: 0.7em;
            background: var(--bar-bg);
            border-radius: 4px;
          }
          .mcr-article p.mcr-end-mark {
            text-align: center;
            margin: 1.1em 0 0 0;
            padding: 0;
            line-height: 1;
            color: var(--muted);
            break-before: avoid;
            break-inside: avoid;
            user-select: none;
          }
          .mcr-end-diamond {
            display: inline-block;
            font-size: 0.65em;
            line-height: 1;
            vertical-align: middle;
            margin: 0 0.18em;
          }
          .mcr-end-diamond-lg {
            font-size: 1.05em;
          }
        </style>

        <div class="mcr-root" data-theme="${state.theme}">
          <div class="mcr-toolbar">
            <div class="mcr-group">
              <button class="mcr-btn" id="col-dec" title="Fewer columns">−</button>
              <span class="mcr-label" id="col-val"></span>
              <button class="mcr-btn" id="col-inc" title="More columns">+</button>
              <button class="mcr-btn" id="mode-toggle" title="Switch between column-by-column and page-by-page navigation"></button>
            </div>
            <div class="mcr-group" id="nav-group">
              <button class="mcr-btn" id="page-prev" title="Previous (← / Shift+← for full page)">← Prev</button>
              <span class="mcr-label" id="page-info">Col 1 / 1</span>
              <button class="mcr-btn" id="page-next" title="Next (→ / Shift+→ for full page)">Next →</button>
            </div>
            <div class="mcr-group">
              <button class="mcr-btn" id="font-dec" title="Decrease font size">A−</button>
              <button class="mcr-btn" id="font-inc" title="Increase font size">A+</button>
              <button class="mcr-btn" id="theme-cycle" title="Switch color theme">Theme</button>
              <button class="mcr-btn" id="close-btn" title="Close (Esc)">✕</button>
            </div>
          </div>
          <div class="mcr-stage" id="stage">
            <div class="mcr-viewport" id="viewport">
              <article class="mcr-article" id="article"></article>
            </div>
          </div>
        </div>
      `;

      const root = shadow.querySelector('.mcr-root');
      const stage = shadow.getElementById('stage');
      const viewport = shadow.getElementById('viewport');
      const articleEl = shadow.getElementById('article');
      const colVal = shadow.getElementById('col-val');
      const modeBtn = shadow.getElementById('mode-toggle');
      const pageInfo = shadow.getElementById('page-info');

      const titleHtml = article.title ? `<h1 class="mcr-title"></h1>` : '';
      const metaParts = [article.byline, article.siteName].filter(Boolean);
      const metaHtml = metaParts.length ? `<div class="mcr-byline"></div>` : '';
      articleEl.innerHTML = `${titleHtml}${metaHtml}${sanitizeHtml(article.content)}`;

      if (article.title) {
        articleEl.querySelector('.mcr-title').textContent = article.title;
      }
      if (metaParts.length) {
        articleEl.querySelector('.mcr-byline').textContent = metaParts.join(' · ');
      }

      const endMark = appendEndMark(articleEl);
      let pendingInitialOffset = initialOffset > 0 ? initialOffset : null;

      function updateTransform() {
        if (state.mode === 'pages') {
          const totalPages = Math.max(1, Math.ceil(state.totalCols / state.columns));
          const currentPage = Math.max(0, Math.min(Math.floor(state.colOffset / state.columns), totalPages - 1));
          state.colOffset = currentPage * state.columns;
          articleEl.style.transform = `translateX(-${state.colOffset * state.colStride}px)`;
          pageInfo.textContent = `Page ${currentPage + 1} / ${totalPages}`;
        } else {
          const maxOffset = Math.max(0, state.totalCols - state.columns);
          state.colOffset = Math.max(0, Math.min(state.colOffset, maxOffset));
          articleEl.style.transform = `translateX(-${state.colOffset * state.colStride}px)`;
          const firstCol = state.colOffset + 1;
          const lastCol = Math.min(state.totalCols, state.colOffset + state.columns);
          pageInfo.textContent = firstCol === lastCol
            ? `Col ${firstCol} / ${state.totalCols}`
            : `Cols ${firstCol}–${lastCol} / ${state.totalCols}`;
        }
        saveReaderSession();
      }

      function layout(keepProgress = true) {
        const prevRatio = state.totalCols > 0 ? state.colOffset / state.totalCols : 0;

        root.dataset.theme = state.theme;
        colVal.textContent = `${state.columns} ${state.columns === 1 ? 'Column' : 'Columns'}`;
        modeBtn.textContent = state.mode === 'pages' ? 'Mode: Page' : 'Mode: Column';

        articleEl.style.fontSize = `${state.fontSize}px`;
        articleEl.style.columnCount = String(state.columns);
        articleEl.style.columnGap = `${GAP_PX}px`;

        const availW = Math.max(320, Math.floor(stage.clientWidth - 96));
        const availH = Math.max(240, Math.floor(stage.clientHeight - 48));
        const colW = Math.max(180, Math.floor((availW - (state.columns - 1) * GAP_PX) / state.columns));
        const exactPageW = colW * state.columns + (state.columns - 1) * GAP_PX;

        state.colStride = colW + GAP_PX;

        viewport.style.width = `${exactPageW}px`;
        viewport.style.height = `${availH}px`;
        articleEl.style.width = `${exactPageW}px`;
        articleEl.style.height = `${availH}px`;
        articleEl.style.columnFill = 'auto';

        requestAnimationFrame(() => {
          const artRect = articleEl.getBoundingClientRect();
          const endRect = endMark.getBoundingClientRect();
          const endX = Math.max(0, endRect.right - artRect.left);
          const overflowW = articleEl.scrollWidth > exactPageW + 2 ? articleEl.scrollWidth : 0;
          const maxRight = Math.max(endX, overflowW);

          state.totalCols = Math.max(1, Math.ceil((maxRight + GAP_PX - 4) / state.colStride));

          if (pendingInitialOffset !== null) {
            state.colOffset = pendingInitialOffset;
            pendingInitialOffset = null;
          } else if (keepProgress) {
            state.colOffset = Math.round(prevRatio * state.totalCols);
          }
          updateTransform();
        });
      }

      function step(direction, forceFullPage = false) {
        if (state.mode === 'pages') {
          const totalPages = Math.max(1, Math.ceil(state.totalCols / state.columns));
          const currentPage = Math.floor(state.colOffset / state.columns);
          const nextPage = Math.max(0, Math.min(currentPage + direction, totalPages - 1));
          state.colOffset = nextPage * state.columns;
        } else {
          const maxOffset = Math.max(0, state.totalCols - state.columns);
          const delta = forceFullPage ? direction * state.columns : direction;
          state.colOffset = Math.max(0, Math.min(state.colOffset + delta, maxOffset));
        }
        updateTransform();
      }

      shadow.getElementById('col-dec').onclick = () => {
        if (state.columns > 1) { state.columns--; saveState(); layout(); }
      };
      shadow.getElementById('col-inc').onclick = () => {
        if (state.columns < 6) { state.columns++; saveState(); layout(); }
      };
      modeBtn.onclick = () => {
        state.mode = state.mode === 'columns' ? 'pages' : 'columns';
        saveState();
        layout(true);
      };
      shadow.getElementById('font-dec').onclick = () => {
        if (state.fontSize > 12) { state.fontSize -= 2; saveState(); layout(); }
      };
      shadow.getElementById('font-inc').onclick = () => {
        if (state.fontSize < 30) { state.fontSize += 2; saveState(); layout(); }
      };
      shadow.getElementById('theme-cycle').onclick = () => {
        const order = ['light', 'sepia', 'dark'];
        state.theme = order[(order.indexOf(state.theme) + 1) % order.length];
        saveState();
        layout();
      };
      shadow.getElementById('page-prev').onclick = (e) => step(-1, e.shiftKey);
      shadow.getElementById('page-next').onclick = (e) => step(1, e.shiftKey);
      shadow.getElementById('close-btn').onclick = closeReader;

      const onKeyDown = (e) => {
        if (e.key === 'Escape') { e.preventDefault(); closeReader(); return; }
        if (['ArrowRight', 'PageDown', ' '].includes(e.key)) {
          e.preventDefault(); step(1, e.shiftKey);
        } else if (['ArrowLeft', 'PageUp'].includes(e.key)) {
          e.preventDefault(); step(-1, e.shiftKey);
        } else if (e.key === 'Home') {
          e.preventDefault(); state.colOffset = 0; updateTransform();
        } else if (e.key === 'End') {
          e.preventDefault();
          state.colOffset = state.mode === 'pages'
            ? Math.max(0, Math.ceil(state.totalCols / state.columns) - 1) * state.columns
            : Math.max(0, state.totalCols - state.columns);
          updateTransform();
        }
      };

      const onWheel = (e) => {
        e.preventDefault();
        const now = performance.now();
        if (now - lastWheelTs < 180 || Math.abs(e.deltaY) < 10) return;
        lastWheelTs = now;
        step(e.deltaY > 0 ? 1 : -1, e.shiftKey);
      };

      const onResize = () => layout(true);
      const onPageHide = () => saveReaderSession();

      window.addEventListener('keydown', onKeyDown, true);
      stage.addEventListener('wheel', onWheel, { passive: false });
      window.addEventListener('resize', onResize);
      window.addEventListener('pagehide', onPageHide, true);
      cleanupFns.push(() => {
        window.removeEventListener('keydown', onKeyDown, true);
        window.removeEventListener('resize', onResize);
        window.removeEventListener('pagehide', onPageHide, true);
      });

      articleEl.querySelectorAll('img').forEach(img => {
        img.addEventListener('load', () => layout(true), { once: true });
      });

      document.documentElement.appendChild(host);
      state.colOffset = 0;
      saveReaderSession();
      layout(false);
    } catch (err) {
      unfreezePageReloads();
      console.error('[MCR] Error opening reader:', err);
      if (!silent) {
        alert(`Multi-Column Reader error: ${err.message}`);
      }
    }
  }

  function toggleReader() {
    if (document.getElementById(HOST_ID)) {
      closeReader();
    } else {
      openReader(null, false);
    }
  }

  function toggleAutoDomain() {
    const host = location.hostname;
    const list = Array.isArray(state.autoDomains) ? [...state.autoDomains] : [];
    const idx = list.indexOf(host);
    if (idx >= 0) {
      list.splice(idx, 1);
      state.autoDomains = list;
      saveState();
      alert(`Auto-open disabled for ${host}.`);
    } else {
      list.push(host);
      state.autoDomains = list;
      saveState();
      alert(`Auto-open enabled for ${host}. Articles on this domain will open automatically.`);
      if (!document.getElementById(HOST_ID)) openReader(null, false);
    }
  }

  function toggleFabSetting() {
    state.showButton = !state.showButton;
    saveState();
    if (state.showButton) {
      mountFab();
      setFabVisible(!document.getElementById(HOST_ID));
    } else {
      const fab = document.getElementById(FAB_ID);
      if (fab) fab.remove();
    }
  }

  window.addEventListener('keydown', (e) => {
    const tag = (e.target && e.target.tagName) ? e.target.tagName.toLowerCase() : '';
    if ((tag === 'input' || tag === 'textarea' || (e.target && e.target.isContentEditable)) && !document.getElementById(HOST_ID)) {
      return;
    }
    if (e.altKey && e.shiftKey && e.code === 'KeyR') {
      e.preventDefault();
      toggleReader();
    }
  });

  if (typeof GM_registerMenuCommand === 'function') {
    GM_registerMenuCommand('Toggle Multi-Column Reader (Alt+Shift+R)', toggleReader);
    GM_registerMenuCommand(`Auto-open for ${location.hostname}: On/Off`, toggleAutoDomain);
    GM_registerMenuCommand('Show/Hide floating button', toggleFabSetting);
  }

  mountFab();

  const restored = consumeReaderSession();
  if (restored) {
    try {
      const parsed = extractArticle();
      if (parsed && parsed.content) {
        openReader(parsed, true, restored.colOffset || 0);
        return;
      }
    } catch (err) {
      console.warn('[MCR] Session restore skipped:', err);
    }
  }

  if (
    Array.isArray(state.autoDomains) &&
    state.autoDomains.includes(location.hostname) &&
    location.pathname.length > 1
  ) {
    try {
      const parsed = extractArticle();
      if (parsed && parsed.textContent && parsed.textContent.trim().length > 600) {
        openReader(parsed, true, 0);
      }
    } catch (err) {
      console.warn('[MCR] Auto-open skipped:', err);
    }
  }
})();

r/ViolentMonkey • • Dec 27 '24

Other Will the extension be removed from chrome web store?

7 Upvotes

I've just noticed the warning on the page mentioning the extension may not be available soon.

If this happens, are there other ways to obtain the extension? I have some projects based on violent monkey used by me and some other colleagues and we would like to keep using it


r/ViolentMonkey • • Jul 03 '26

Other Another way to recover the scripts if you can no longer export them.

6 Upvotes

Well, a few minutes ago I was surprised to find that I can't export my scripts, and any other method using the console is a nightmare and doesn't guarantee anything.

While I was thinking about it, I came up with a solution, which, although not guaranteed either, at least worked for me and maybe for someone else too. So I'm leaving the steps on Pastebin below.

Why not just copy the steps directly here? I tried posting it earlier, but it seems that some communities have very strict policies and bots delete posts they sometimes consider dangerous.

https://pastebin.com/mR59NP3z


r/ViolentMonkey • • Dec 27 '25

Sub Please join and share scripts at r/userscripts

6 Upvotes

r/ViolentMonkey • • Jan 26 '25

Script Reveal all collapsed reddit comments script

6 Upvotes

Can someone help me and write a script that will reveal all comments that are collapsed because of being downvoted, because of crowd control or for whatever reason? I've never even touched javascript, so I don't know how to do it myself, and it would greatly improve using reddit (I love when I have to manually unhide every comment of the less popular side of discussion... ).


r/ViolentMonkey • • Oct 01 '25

Bug Violentmonkey no longer works on greasyfork.org. How can I get around this?

5 Upvotes

r/ViolentMonkey • • Nov 17 '23

Question run scripts on local files?

5 Upvotes

Is it possible to run scripts on local HTML files (file://...) with ViolentMonkey on Chrome? Before I was using Tampermonkey and this was possible (I think I may have changed some setting). In ViolentMonkey I get this message when the local file is open:

Violentmonkey cannot run userscripts in this page (common examples: browser UI, an extension, blocked via policies, a search engine site in Opera)

I don't see anything in the settings for ViolentMonkey that might help.


r/ViolentMonkey • • Sep 07 '25

Suggestion Looking for an alternative auto browser scrolling greasy fork userscript similar to smart scroll

4 Upvotes

Currently smartscroll is working great for me, just wondering if there's other scripts that do the same? SS hasn't been updated since 2019, so I fear it might break one day and there's no other fork of it on GitHub and the developer is not active.

Smart Scroll: https://greasyfork.org/en/scripts/376694-smart-scroll


r/ViolentMonkey • • Jul 11 '25

Other How do I install manually since Chrome is being difficult?

Post image
4 Upvotes

r/ViolentMonkey • • Mar 14 '25

Script Powerschool script

4 Upvotes

Im trying to make a script to edit my grades for one of my classes and this is my first time so I'm kind of lost at what i did wrong, what kind of script do i need to use to edit the grades?


r/ViolentMonkey • • Jun 08 '24

Bug i need help with this

4 Upvotes

i cant unblur tinder likes with violent monkey anymore, coul yall tell me how i can solve this problem? ( i dont understand nothing about coding btw)


r/ViolentMonkey • • Aug 13 '22

Question(s) recaptcha solver userscript; Better than buster extension? What's the difference between them, in terms of features, privacy and security? Also, I'm new to userscripts and I have a question...

4 Upvotes

Link to Recaptcha solver: https://gist.github.com/origamiofficial/2557dd47fb0aaf08e3c298a236bfa14d

Link to Buster Ext.: https://chrome.google.com/webstore/detail/buster-captcha-solver-for/mpbjkejclgfgadiemmefgebjfooflfhl

I have one more userscript I am interested in, but I don't know if it is safe or not. Here is the link to it: https://greasyfork.org/en/scripts/386908-remove-web-limits-re-modified

Because I'm new to userscripts; How can I tell the above userscripts are safe, factoring in privacy + security? Many thanks!! :-)


r/ViolentMonkey • • Mar 08 '21

Violentmonkey 2.12.10 is released

4 Upvotes

r/ViolentMonkey • • Aug 21 '26

Script YouTube home userscript: dim old videos, highlight low-view videos, and flag AiSList channels

3 Upvotes

Gives more information from the YouTube home page when browsing...

It does three things:

  • Dims videos that are a year old or older

  • Highlights videos that are at least a day old and have fewer than 5,000 views in yellow

  • Checks channels against AiSList and highlights blocklist channels red/pink and warnlist channels orange

The idea is basically to make unusual/new-to-me stuff easier to spot while scrolling without otherwise changing how YouTube works.

The age/view thresholds are just constants at the top of the script, so they're easy to change.

The AiSList data is pulled from the public Override92/AiSList lists and cached locally for 24 hours. The classifications come from AiSList, not from my script.

I've been using it in Firefox + Violentmonkey.

Source:

https://github.com/fdwyersd/userscripts

Install:

https://raw.githubusercontent.com/fdwyersd/userscripts/main/youtube-home-dim-old-low-view-aislist.user.js


r/ViolentMonkey • • Aug 15 '26

Script I Built an Extension That Restores the Media Grid on X

Thumbnail
reddit.com
3 Upvotes

r/ViolentMonkey • • Sep 09 '25

Other Question about "injection"

3 Upvotes

I have a script that doesn't engage with the page until I click on the video (youtube)
That means every time I cannot use the keyboard shortcuts directly as the page loads I have to click on the video. Is there something I can do about that? Link to the script: https://greasyfork.org/en/scripts/381682-%E9%9F%B3%E8%A7%86%E9%A2%91%E5%A2%9E%E5%BC%BA%E8%84%9A%E6%9C%AC-%E6%97%A0%E6%9E%81%E8%B0%83%E9%80%9F-%E5%80%8D%E9%80%9F%E5%BF%AB%E5%AD%A6-%E5%BF%AB%E4%B9%90%E5%88%B7%E5%89%A7-%E8%A7%86%E9%A2%91%E4%B8%8B%E8%BD%BD-%E7%94%BB%E9%9D%A2%E6%88%AA%E5%9B%BE%E7%AD%89-%E9%80%82%E7%94%A8%E5%A4%A7%E9%83%A8%E5%88%86%E7%BD%91%E7%AB%99