NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Joyreactor Longpost Minimizer // @namespace http://tampermonkey.net/ // @version 0.2 // @description Добавляет в нижний левый угол кнопку для сворачивания длиннопостов // @author Gertykhon // @updateURL https://openuserjs.org/meta/Gertykhon/Joyreactor_Longpost_Minimizer.meta.js // @include *reactor.cc* // @include *joyreactor.cc* // @include *jr-proxy.com* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; /* * Leoric(@joyreactor.cc) */ var cuts = [], last, i = 0; var btn = document.createElement('div'); btn.innerHTML = '<span>↥</span>'; btn.style = 'position:fixed; left:10px; bottom:15px; background-color:white; opacity:0.7; ' + 'cursor:pointer; padding:5px; font-size: 20pt; z-index:9999;'; var loop = setInterval(function () { for (var k of document.getElementsByClassName('post_content_expand')) { if (k.style.display == 'block') cuts.push(k); } var al = document.getElementsByClassName('allow_long')[0]; if (al) { al.classList.remove('allow_long'); al.classList.add('post_content_cut'); al.style = 'max-height: 100%;'; cuts.push(al.parentNode.getElementsByClassName('post_content_expand')[0]); } if (cuts.length > 0) { document.body.appendChild(btn); clearInterval(loop); } if (i > 9) clearInterval(loop); i++; }, 1000); btn.onclick = function () { for (var j of document.querySelectorAll('div[style="max-height: 100%;"]')) { j.style = ''; last = j; } for (var k of cuts) { k.style.display = 'block'; } if (last) last.parentNode.parentNode.parentNode.scrollIntoView(); setTimeout(function () { if (last) last.parentNode.getElementsByClassName('post_content_expand')[0].scrollIntoView(); last = null; }, 500); }; })();