Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name dota replies
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description перед отправкой поста нажать кнопку "replies"
- // @author joepesch
- // @match https://2ch.hk/vg/res/*.html
- // @icon https://www.google.com/s2/favicons?sz=64&domain=2ch.hk
- // @grant none
- // ==/UserScript==
- const sub = (thId, str) => {
- let data = $.ajax({
- async: false,
- url: `https://2ch.hk/vg/res/${thId}.json`,
- }).responseJSON;
- let posts = data.threads[0].posts;
- let rev = {}
- posts.forEach((e, i) => rev[e.num] = i + 1);
- return str.replace(/>>(\d+)/, (...g) => rev[g[1]]);
- }
- $(document).ready(function () {
- const button_html = '<button type="button" class="dotareplies button desktop">replies</button>';
- $(".postform").each(function () {
- $(this).children(".postform__raw").first().append(button_html);
- });
- $(".dotareplies").click(function () {
- let thId = location.pathname.match(/\d+/)[0];
- $("#shampoo").val(sub(thId, $("#shampoo").val()));
- });
- });
Add Comment
Please, Sign In to add comment