Skip to content

Instantly share code, notes, and snippets.

@Gkjsdll
Last active March 16, 2023 01:47
Show Gist options
  • Save Gkjsdll/00dd9a16aa17bc6c52a3eae9d0ae69b3 to your computer and use it in GitHub Desktop.
Save Gkjsdll/00dd9a16aa17bc6c52a3eae9d0ae69b3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name BiliBili Be-gone
// @namespace http://tampermonkey.net/
// @version 0.2.0
// @description try to take over the world!
// @author Zack (Gkjsdll) Winchell
// @icon https://i.imgur.com/mBU8lYf.png
// @match https://imperfectcomic.com/
// @match https://leviatanscans.com/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
const beGoneFuncs = {
'imperfectcomic.com': () => {
const coversContainer = document.getElementById('loop-content');
const bilibiliTags = coversContainer.querySelectorAll('.bilibili');
bilibiliTags.forEach((tag) => {
tag.closest('.page-item-detail').parentElement.remove();
});
const remainingCovers = coversContainer.querySelectorAll('.page-item-detail');
const existingRows = [...coversContainer.querySelectorAll('.page-listing-item')];
existingRows.forEach((row) => row.remove());
let pageListingItem = null;
for (let i = 0; i < remainingCovers.length; i += 1) {
if (i % 6 === 0) {
pageListingItem = makePageListingItem();
coversContainer.append(pageListingItem);
}
pageListingItem.children[0]
.append(makeCol(remainingCovers[i]));
}
function makeCol(el) {
const col = document.createElement('div');
col.className = 'col-6 col-md-2 badge-pos-1';
col.append(el);
return col;
};
function makePageListingItem() {
const pageListingItem = document.createElement('div');
pageListingItem.className = 'page-listing-item';
const row = document.createElement('div');
row.className = 'row row-eq-height';
pageListingItem.append(row);
return pageListingItem;
};
},
'leviatanscans.com': () => {
const coversContainer = document.getElementById('loop-content');
const bilibiliTags = coversContainer.querySelectorAll('.bilibili');
bilibiliTags.forEach((tag) => {
tag.closest('.page-item-detail').parentElement.remove();
});
const remainingCovers = coversContainer.querySelectorAll('.page-item-detail');
const existingRows = [...coversContainer.querySelectorAll('.page-listing-item')];
existingRows.forEach((row) => row.remove());
let pageListingItem = null;
for (let i = 0; i < remainingCovers.length; i += 1) {
if (i % 6 === 0) {
pageListingItem = makePageListingItem();
coversContainer.append(pageListingItem);
}
pageListingItem.children[0]
.append(makeCol(remainingCovers[i]));
}
const loadMoreEl = document.querySelector('.load-title').closest('a');
loadMoreEl.addEventListener('click', readyBbg);
function makeCol(el) {
const col = document.createElement('div');
col.className = 'col-6 col-md-2 badge-pos-2';
col.append(el);
return col;
};
function makePageListingItem() {
const pageListingItem = document.createElement('div');
pageListingItem.className = 'page-listing-item';
const row = document.createElement('div');
row.className = 'row row-eq-height';
pageListingItem.append(row);
return pageListingItem;
};
async function readyBbg() {
const seriesCount = coversContainer.querySelectorAll('.page-item-detail').length;
while (seriesCount === coversContainer.querySelectorAll('.page-item-detail').length) {
await new Promise((resolve) => setTimeout(resolve, 50));
}
loadMoreEl.removeEventListener('click', readyBbg);
beGoneFuncs[domain]();
}
},
};
const domain = (() => {
const regExp = /^(?:.*\.){0,1}(.*\..*)$/;
const hostname = window.location.hostname;
const domain = hostname.match(regExp)[1];
return domain;
})();
beGoneFuncs[domain]();
document.addEventListener('keypress', function (event) {
if (event.key !== 'b') {
return;
}
beGoneFuncs[domain]();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment