Last active
April 15, 2023 11:33
-
-
Save BoberMod/93fa5183e7649f328276361d7d20a9ac to your computer and use it in GitHub Desktop.
This script will load 100 comments instead of the standard 20 on shikimori
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Shikimori comments loader | |
// @name:ru Загрузчик комментариев Shikimori | |
// @namespace https://shikimori.org/ | |
// @version 0.9 | |
// @description Load 100 comments instead of the standard 20 | |
// @description:ru Загружает 100 комментариев вместо 20 стандартных на Shikimori | |
// @author BoberMod | |
// @match https://*.shikimori.org/* | |
// @match https://shikimori.one/* | |
// @match https://shikimori.me/* | |
// @downloadURL https://gist.github.com/BoberMod/93fa5183e7649f328276361d7d20a9ac/raw/shikimori-comment-loader.user.js | |
// @updateURL https://gist.github.com/BoberMod/93fa5183e7649f328276361d7d20a9ac/raw/shikimori-comment-loader.user.js | |
// @grant none | |
// ==/UserScript== | |
// Settings | |
// СКОЛЬКО КОММЕНТАРИЕВ ЗАГРУЖАТЬ ЗА 1 РАЗ | |
const commentsPerClick = 100; //НЕ СТОИТ ДЕЛАТЬ ЗНАЧЕНИЕ БОЛЬШЕ 150-200! | |
function change() { | |
"use strict"; | |
let loader = document.getElementsByClassName("comments-loader")[0]; | |
if (!loader) { return false; } | |
let numberOfComments = loader.getAttribute("data-count"); | |
let skipLink = loader.getAttribute("data-clickloaded-url-template").replace(/SKIP\/\d{1,2}/g, `SKIP/${commentsPerClick}`); | |
loader.setAttribute("data-limit", commentsPerClick); | |
loader.setAttribute("data-clickloaded-url-template", skipLink); | |
if (numberOfComments <= commentsPerClick) { | |
loader.innerText = `Загрузить ${numberOfComments} из ${numberOfComments} комментариев`; | |
} | |
else { | |
loader.innerText = `Загрузить ещё ${commentsPerClick} из ${numberOfComments} комментариев`; | |
} | |
} | |
function onload(fn) { | |
document.addEventListener('page:load', fn); | |
document.addEventListener('turbolinks:load', fn); | |
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") { | |
fn(); | |
} else { | |
document.addEventListener('DOMContentLoaded', fn); | |
} | |
} | |
onload(change); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment