Skip to content

Instantly share code, notes, and snippets.

@xim
Last active February 1, 2024 22:11

Revisions

  1. xim revised this gist Feb 1, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions mangasee123-gap-persisting.user.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,8 @@
    // @description Script that remembers the "gap" setting per manga
    // @author xim
    // @match https://mangasee123.com/read-online/*
    // @downloadURL https://gist.github.com/xim/581c409b924ee01e4bc9bf5e9fa2abfc/raw/mangasee123-gap-persisting.user.js
    // @updateURL https://gist.github.com/xim/581c409b924ee01e4bc9bf5e9fa2abfc/raw/mangasee123-gap-persisting.user.js
    // @icon https://www.google.com/s2/favicons?sz=64&domain=mangasee123.com
    // @grant GM_getValue
    // @grant GM_setValue
  2. xim created this gist Feb 1, 2024.
    53 changes: 53 additions & 0 deletions mangasee123-gap-persisting.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    // ==UserScript==
    // @name Mangasee123 page gap persisting
    // @namespace https://gist.github.com/xim
    // @version 2024-02-01
    // @description Script that remembers the "gap" setting per manga
    // @author xim
    // @match https://mangasee123.com/read-online/*
    // @icon https://www.google.com/s2/favicons?sz=64&domain=mangasee123.com
    // @grant GM_getValue
    // @grant GM_setValue
    // ==/UserScript==

    function set_gap(manga, gap) {
    console.log('set_gap', manga, gap);
    var data = JSON.parse(GM_getValue('pageGaps', '{}'));
    data[manga] = gap;
    GM_setValue('pageGaps', JSON.stringify(data));
    }

    (function() {
    'use strict';

    const manga = document.querySelector('i.fa-book').parentElement.href.split('/')[4];
    console.log(manga);
    if (!manga) {
    console.log('Unable to determine manga name');
    return;
    }

    const button = document.querySelector('button[ng-click="vm.ToggleGap()"]');
    var gap = button.children[0].classList.contains('fa-compress');

    const clone = button.cloneNode(true);
    function toggle() {
    button.click();
    clone.children[0].className = gap ? 'fas fa-compress' : 'fas fa-expand';
    }

    clone.onclick = function() {
    gap = !gap;
    set_gap(manga, gap);
    toggle();
    };
    button.style.setProperty('display', 'none', 'important');
    button.insertAdjacentElement('afterend', clone);

    const data = JSON.parse(GM_getValue('pageGaps', "{}"));
    if (data[manga] !== undefined && data[manga] !== gap) {
    gap = data[manga];
    console.log('Setting', manga, 'gap to', gap, 'because of persisted data');
    toggle();
    }
    })();