Skip to content

Instantly share code, notes, and snippets.

@xim
Last active February 1, 2024 22:11
Show Gist options
  • Save xim/581c409b924ee01e4bc9bf5e9fa2abfc to your computer and use it in GitHub Desktop.
Save xim/581c409b924ee01e4bc9bf5e9fa2abfc to your computer and use it in GitHub Desktop.
Mangasee123 page gap persisting
// ==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/*
// @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
// ==/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();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment