Skip to content

Instantly share code, notes, and snippets.

@xim
Last active October 30, 2024 06:27
Show Gist options
  • Save xim/9ca907c77abf0687d1beac910888966d to your computer and use it in GitHub Desktop.
Save xim/9ca907c77abf0687d1beac910888966d to your computer and use it in GitHub Desktop.
Mangaread/nightcomic/manhuafast page gap toggler
// ==UserScript==
// @name Mangaread/nightcomic/manhuafast page gap toggler
// @namespace https://gist.github.com/xim
// @version 2024-10-30
// @description Running this toggles the "no-gap" css class on all .page-break page elements and persists per manga
// @author xim
// @match https://www.mangaread.org/*
// @match https://www.nightcomic.com/*
// @match https://manhuafast.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=mangaread.org
// @downloadURL https://gist.github.com/xim/9ca907c77abf0687d1beac910888966d/raw/mangaread-page-gap-toggler.user.js
// @updateURL https://gist.github.com/xim/9ca907c77abf0687d1beac910888966d/raw/mangaread-page-gap-toggler.user.js
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
function do_toggle(gap) {
var pages = document.getElementsByClassName('page-break');
for (const page of pages) {
if (gap) {
page.classList.remove('no-gaps');
} else {
page.classList.add('no-gaps');
}
}
}
function toggle_gap(manga) {
var data = JSON.parse(GM_getValue('pageGaps', '{}'));
const gap = !data[manga];
do_toggle(gap);
data[manga] = gap;
GM_setValue('pageGaps', JSON.stringify(data));
}
(function() {
'use strict';
const manga = window.location.pathname.split('/')[2];
if (!manga) {
return;
}
var icon = document.createElement('i');
icon.classList.add('icon');
icon.classList.add('ion-logo-javascript');
var link = document.createElement('a');
link.classList.add('wp-manga-action-button');
link.onclick = () => { toggle_gap(manga) };
link.appendChild(icon);
var li = document.createElement('li');
li.appendChild(link);
var list = document.getElementsByClassName('action_list_icon')[0];
list.appendChild(li);
const data = JSON.parse(GM_getValue('pageGaps', "{}"));
if (data[manga]) {
do_toggle(true);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment