Created
November 5, 2024 09:42
-
-
Save PsixokoT/a148ed981a9ddec4607404b1b9e0fdd4 to your computer and use it in GitHub Desktop.
Lepra comments raiting filter
This file contains hidden or 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 Lepra comments raiting filter | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match https://*.leprosorium.ru/comments/* | |
| // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const control = document.querySelector('.b-comments_controls'); | |
| const dropBox = document.createElement('select'); | |
| const options = ['Только с рейтингом выше ...', '0', '50', '100', '150'].map((text, i) =>{ | |
| const option = document.createElement('option'); | |
| option.value = option.text = text; | |
| option.disabled = option.selected = i == 0; | |
| dropBox.appendChild(option); | |
| return option; | |
| }) | |
| control.appendChild(dropBox); | |
| dropBox.onchange = () => { | |
| const rating = parseInt(options[dropBox.selectedIndex].value); | |
| const comments = document.getElementsByClassName('comment'); | |
| Array.from(comments).forEach((comment) => { | |
| comment.style.display = parseInt(comment.querySelector('.vote_result').textContent) >= rating ? '': 'none'; | |
| }); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment