NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Joyreactor post rating // @version 0.1.2 // @description Shows post ratings for logged in users / показывает оценки постов для залогиненных пользователей // @author Gertykhon // @updateURL https://openuserjs.org/meta/Gertykhon/Joyreactor_post_rating.meta.js // @include *reactor.cc* // @include *joyreactor.cc* // @include *jr-proxy.com* // @grant GM_xmlhttpRequest // @license MIT // ==/UserScript== (function () { 'use strict'; /* * Leoric(@joyreactor.cc) */ //в хроме и его клонах на главной не показывает рейтинг постов из фендомов var auto = true; //true - always show rating / всегда показывать оценку постов //false - show rating of one post by сlicking '--' / показать оценку поста при клике по '--' var brUA = window.navigator.userAgent; var postRatingsAll = document.getElementsByClassName("post_rating"); var postRatings = []; for (var k of postRatingsAll) { if (k.parentNode.classList.contains('ufoot_first') && (k.innerHTML.includes('--') || k.innerHTML.length === 0)) postRatings.push(k); } for (var i of postRatings) { if (i.innerHTML.length === 0) i.innerHTML = '<span>--</span>'; i.firstChild.innerHTML = i.firstChild.innerHTML.replace('--', '<span>--</span>'); i.firstChild.getElementsByTagName('span')[0].addEventListener('click', function (event) { if (event.target.innerHTML.includes('--')) { var postURL = event.target.parentNode.parentNode.parentNode.getElementsByClassName('link')[0].href; if ((brUA.indexOf("Chrome")) != -1) { fetch(postURL, { credentials: 'omit', mode: 'cors' }) .then(function (response) { return response.text(); }) .then(function (resp) { showR(resp); }) .catch(function (err) { console.log('JR рейтинг постов: fetch failed. ' + err); }); } else { GM_xmlhttpRequest({ method: "GET", url: postURL, anonymous: true, responseType: "text", onload: function (resp) { showR(resp.responseText); }, onerror: function (resp) { console.log('JR рейтинг постов: GM_xmlhttpRequest failed.' + (resp.status ? resp.statusText : '')); } }); } } function showR(page) { var rPos = page.lastIndexOf('<span class="post_rating"><span>') + 32; var crudeValue = page.substring(rPos, rPos + 10); var rating = crudeValue.substring(0, crudeValue.indexOf('<')); event.target.innerHTML = event.target.innerHTML.replace('--', rating); } }); } if (auto) { var j = 0; var autoShow = setInterval(function () { if (j == postRatings.length) { clearInterval(autoShow); } else { var event = new MouseEvent('click', { 'bubbles': true, 'cancelable': true }); postRatings[j].firstChild.getElementsByTagName('span')[0].dispatchEvent(event); j++; } }, 1000); } })();