Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name govnoscript
- // @namespace http://govnokod.ru
- // @description expand hidden comments and hide pidors
- // @include http://govnokod.ru/*
- // @include http://*.govnokod.ru/*
- // @exclude http://govnokod.ru/comments
- // @exclude http://*.govnokod.ru/comments
- // @version 1
- // @grant none
- // ==/UserScript==
- pidors = ["passiv"]
- function is_pidor(nick) {
- for (var pattern of pidors) {
- re = new RegExp("^" + pattern + "$");
- if (re.test(nick)) {
- return true;
- }
- }
- return false;
- }
- function fixup_comments() {
- var pidor_comments = [];
- var hidden_comments = [];
- for (var comment of document.getElementsByClassName("hcomment")) {
- //console.log("Process comment: ", comment, comment.innerHTML);
- var pidor = false;
- for (var author of comment.getElementsByClassName("entry-author")) {
- for (var ref of author.getElementsByTagName("A")) {
- if (is_pidor(ref.innerHTML)) {
- //console.log("Hide comment: ", comment, comment.innerHTML);
- pidor_comments.push(comment);
- pidor = true;
- }
- break;
- }
- break;
- }
- if (pidor) {
- continue;
- }
- for (var body of comment.getElementsByClassName("entry-comment")) {
- if (body.classList.contains("entry-comment-hidden")) {
- //console.log("Unhide comment: ", comment, comment.innerHTML);
- hidden_comments.push(comment);
- }
- break;
- }
- }
- for (var comment of pidor_comments) {
- for (var body of comment.getElementsByClassName("entry-comment")) {
- if (body.getElementsByClassName("hidden-text").length == 0) {
- body.innerHTML = "<span class=\"hidden-text\"><a href=\"#\" class=\"ajax\">показать все, что скрыто</a></span>" + body.innerHTML
- }
- if (!body.classList.contains("entry-comment-hidden")) {
- body.classList.add("entry-comment-hidden")
- }
- break;
- }
- }
- for (var comment of hidden_comments) {
- for (var body of comment.getElementsByClassName("entry-comment")) {
- for (var elem of body.getElementsByClassName("hidden-text")) {
- if (elem.tagName == "SPAN") {
- body.removeChild(elem);
- break;
- }
- }
- body.classList.remove("entry-comment-hidden");
- break;
- }
- }
- }
- fixup_comments()
- var observer = new window.MutationObserver(function(mutations, observer) {
- fixup_comments()
- });
- observer.observe(document, {
- subtree: true,
- childList: true
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement