Update userscript.js
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name JRH: JoyReactor Helper
|
||||
// @version 2.0
|
||||
// @version 2.1
|
||||
// @author DmitriyMX
|
||||
// @match http://joy.reactor.cc/*
|
||||
// @grant none
|
||||
@@ -54,7 +54,11 @@ function createTreeButton(listId) {
|
||||
* Добавляем кнопку сворачивания комментариев
|
||||
*/
|
||||
function collapseTreeComments() {
|
||||
Array.from(document.querySelectorAll('div.comment'))
|
||||
var blocks = document.getElementsByClassName('post_comment_list');
|
||||
var commentBlock = blocks.length === 2 ? blocks[1] : blocks[0];
|
||||
|
||||
Array.from(commentBlock.querySelectorAll('div.comment'))
|
||||
.filter(elm => { return elm.nextElementSibling !== null; })
|
||||
.filter(elm => { return elm.nextElementSibling.children.length > 0; })
|
||||
.forEach(elm => {
|
||||
var listId = elm.nextElementSibling.id;
|
||||
@@ -66,11 +70,64 @@ function isPostPage() {
|
||||
return document.URL.match(/http?:\/\/joy\.reactor\.cc\/post/) !== null
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаляем лишние элементы с сайта
|
||||
*/
|
||||
function removeExcessElements() {
|
||||
// Удаляем пункты меню "Люди" и "О проекте"
|
||||
Array.from(document.querySelectorAll('#navlist li'))
|
||||
.filter(elm => { return elm.querySelector('a').text === "Люди"
|
||||
|| elm.querySelector('a').text === "О проекте" })
|
||||
.forEach(elm => { elm.remove() });
|
||||
|
||||
// Удаляем правую колонку
|
||||
document.getElementById('sidebar').remove();
|
||||
|
||||
// Косметические исправления
|
||||
var width = '930px';
|
||||
document.getElementById('header').style.width = width;
|
||||
document.getElementById('page').style.width = width;
|
||||
document.getElementById('topbar').children[0].style.width = width;
|
||||
document.getElementById('container').style.minWidth = '0';
|
||||
|
||||
// Переключатель языков
|
||||
Array.from(document.getElementsByClassName('lang_select')).forEach(elm => { elm.remove() });
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаляем лишние элементы из поста
|
||||
*/
|
||||
function removeExcessElementsInPost() {
|
||||
// Удаляем "Тренды" и "Фэндомы"
|
||||
var elements = document.getElementsByClassName('additional_info');
|
||||
if (elements.length === 1) {
|
||||
elements[0].remove();
|
||||
}
|
||||
|
||||
// Удаляем "Похожие посты"
|
||||
elements = Array.from(document.getElementsByClassName('mainheader'))
|
||||
.filter(elm => { return elm.innerText === "Похожие посты" });
|
||||
if (elements.length === 1) {
|
||||
elements[0].nextElementSibling.remove();
|
||||
elements[0].remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Все "новые комментарии" перестают подсвечиваться
|
||||
*/
|
||||
function unNewComments() {
|
||||
document.querySelectorAll('.new').forEach(elm => { elm.classList.toggle('new') });
|
||||
}
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
removeExcessElements();
|
||||
fixNofollowLinks();
|
||||
if (isPostPage()) {
|
||||
removeExcessElementsInPost();
|
||||
collapseTreeComments();
|
||||
unNewComments();
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user