SHOW:
|
|
- or go back to the newest paste.
| 1 | // ==UserScript== | |
| 2 | // @name 2ch.hk | Сортировка по ответам | |
| 3 | // @version 0.1 | |
| 4 | // @match ://2ch.hk/*/res/*.html | |
| 5 | // @icon https://2ch.hk/favicon.ico | |
| 6 | // @grant none | |
| 7 | // ==/UserScript== | |
| 8 | ||
| 9 | (function () {
| |
| 10 | - | "use strict"; |
| 10 | + | "use strict"; |
| 11 | ||
| 12 | - | function reply_count($post) {
|
| 12 | + | function reply_count($post) {
|
| 13 | - | return $post.querySelector(".post__refmap").childElementCount;
|
| 13 | + | return $post.querySelector(".post__refmap").childElementCount;
|
| 14 | } | |
| 15 | ||
| 16 | if (document.querySelector("#de-panel-info")) {
| |
| 17 | - | .querySelector(".thread-nav__inner")
|
| 17 | + | |
| 18 | - | .insertAdjacentHTML( |
| 18 | + | .querySelector(".de-parea")
|
| 19 | .children[0].insertAdjacentHTML( | |
| 20 | "beforeend", | |
| 21 | - | ); |
| 21 | + | '[<span><input type="checkbox" id="sort-checkbox"> Сортировать по ответам</span>]' |
| 22 | ); | |
| 23 | - | const $thread = document.querySelector(".thread");
|
| 23 | + | } else {
|
| 24 | - | //$thread.style.display = "flex"; |
| 24 | + | |
| 25 | - | $thread.style["flex-direction"] = "column"; |
| 25 | + | .querySelector(".thread-nav__inner")
|
| 26 | - | $thread.children[0].style.order = -1000; // fix op-post |
| 26 | + | .insertAdjacentHTML( |
| 27 | "beforeend", | |
| 28 | - | document.querySelector("#sort-checkbox").addEventListener("change", (el) => {
|
| 28 | + | |
| 29 | - | if (el.target.checked) {
|
| 29 | + | ); |
| 30 | - | $thread.style.display = "flex"; |
| 30 | + | } |
| 31 | - | const posts = document.querySelectorAll(".thread__post");
|
| 31 | + | |
| 32 | - | posts.forEach(($post) => {
|
| 32 | + | const $thread = document.querySelector(".thread");
|
| 33 | - | $post.style.order = -reply_count($post); |
| 33 | + | //$thread.style.display = "flex"; |
| 34 | - | }); |
| 34 | + | $thread.style["flex-direction"] = "column"; |
| 35 | - | } else {
|
| 35 | + | $thread.children[0].style.order = -1000; // fix op-post |
| 36 | - | $thread.style.display = "block"; |
| 36 | + | |
| 37 | - | } |
| 37 | + | document.querySelector("#sort-checkbox").addEventListener("change", (el) => {
|
| 38 | - | }); |
| 38 | + | if (el.target.checked) {
|
| 39 | - | })(); |
| 39 | + | $thread.style.display = "flex"; |
| 40 | - | |
| 40 | + | const posts = document.querySelectorAll(".thread__post");
|
| 41 | posts.forEach(($post) => {
| |
| 42 | $post.style.order = -reply_count($post); | |
| 43 | }); | |
| 44 | } else {
| |
| 45 | $thread.style.display = "block"; | |
| 46 | } | |
| 47 | }); | |
| 48 | })(); |