Pages:
Author

Topic: [HACK] One-click mod report, not for the faint of heart - page 2. (Read 2048 times)

HCP
legendary
Activity: 2086
Merit: 4361
I thought it's 300 good reports... HCP, please report 52 posts and let us know if you see it Wink
Can finally confirm... you need to get it to 300 good reports... I had a bunch of "unhandled" that I had hoped would push me up, but eventually found a few "gems" to report. Once I hit that 300 "good" then the "view report history" function was available.
legendary
Activity: 1232
Merit: 1080
What a awesome idea especially the queue feature I think that something like this should be added in natively into the forum as a feature it would make reporting posts on mass much easier maybe only give the option to those that have over 5000 good reports or something.

What's the drawbacks of using this via Tor? I haven't really looked at the code used but can anyone verify whether this would compromise anonymity? I'm currently reporting hundreds of posts a day and if I could make that more efficient then I think that would benefit both the forum and myself.
copper member
Activity: 2562
Merit: 2510
Spear the bees
Let me just say, being able to report an entire page at once is amazing. How satisfying it is to see everything grayed out immediately...
Rather than add in buttons, just querySelectorAll("div.post") and immediately report_post with a pre-designated message. This definitely curbs burst-posting spammers, hard.

Most users outside of the * discussion boards will never need to see the use of my "MASS SPAM" button. Smiley

Addendum: increase your promise timeout value if you are reporting a lot of posts.
staff
Activity: 3304
Merit: 4115
Fantastic tool that I've only just come across I'm sure will help us curb the oncoming invasion of spam due to the recent surge in price. Always appreciate anyone who dedicates their time in improving the forum by reporting content. Haven't tested the code myself or used it, but thanks for making something like this!

I'm fully expecting next time theymos releases the reporting stats that at least 10 people have 100k reports Wink
copper member
Activity: 2562
Merit: 2510
Spear the bees
Bump. Doubled my reports over two days. Notched the accuracy up 1%.
legendary
Activity: 2758
Merit: 6830
I thought it's 300 good reports... HCP, please report 52 posts and let us know if you see it Wink
Ops... you are right. Just did some research and found this:

No, it's most likely 300 good reports.
I don't have the link, and my repot "baseline" is:
Quote
You have reported 313 posts with 97% accuracy (293 good, 11 bad, 9 unhandled).
Right okay. That's interesting. Let us know once you get those 7 good reports
I now have the link. Unfortunately, I didn't quite make the 300 mark, but overshot to 301 Tongue
Quote
You have reported 321 posts with 97% accuracy (301 good, 11 bad, 9 unhandled)
legendary
Activity: 3654
Merit: 8909
https://bpip.org
Is that page meant to display a list of posts you have reported? All I see is my a brief overview of my "stats"... "You have reported 248 posts with 100% accuracy..." etc... but I don't see a list? Huh
You need to report 500 posts to see that list.

I thought it's 300 good reports... HCP, please report 52 posts and let us know if you see it Wink
legendary
Activity: 2758
Merit: 6830
Is that page meant to display a list of posts you have reported? All I see is my a brief overview of my "stats"... "You have reported 248 posts with 100% accuracy..." etc... but I don't see a list? Huh
You need to get 300 good reports to see that list.

edit: 300 not 500.
HCP
legendary
Activity: 2086
Merit: 4361
Is that page meant to display a list of posts you have reported? All I see is my a brief overview of my "stats"... "You have reported 248 posts with 100% accuracy..." etc... but I don't see a list? Huh
legendary
Activity: 2240
Merit: 3150
₿uy / $ell ..oeleo ;(
That's perfect. Works great on chrome.
Just wondering if it is possible for someone to add a link to the report history on the menu? It's will be easy to click and see your report history. Now i have to report a random post just to click the link there.


Someone said I don't use enough spreads... so here you go:

Code:
[...document.querySelectorAll(".maintab_back")].slice(-1)[0].insertAdjacentHTML('beforebegin', 'My Reports');

Put it in the extension or in a userscript. Will add "MY REPORTS" before "LOGOUT". Adjust slice parameters to put it elsewhere.

That was quick, thank you Smiley
legendary
Activity: 3654
Merit: 8909
https://bpip.org
That's perfect. Works great on chrome.
Just wondering if it is possible for someone to add a link to the report history on the menu? It's will be easy to click and see your report history. Now i have to report a random post just to click the link there.


Someone said I don't use enough spreads... so here you go:

Code:
[...document.querySelectorAll(".maintab_back")].slice(-1)[0].insertAdjacentHTML('beforebegin', 'My Reports');

Put it in the extension content script bct-content.js (global code - outside of functions) or in a userscript. This will add "MY REPORTS" before "LOGOUT". Adjust slice parameters to put it elsewhere.
legendary
Activity: 2240
Merit: 3150
₿uy / $ell ..oeleo ;(
That's perfect. Works great on chrome.
Just wondering if it is possible for someone to add a link to the report history on the menu? It's will be easy to click and see your report history. Now i have to report a random post just to click the link there.
HCP
legendary
Activity: 2086
Merit: 4361
If anyone cares, I managed to get this working for Chrome... Tongue

I had to use the Mozilla webextension-polyfill library to wrap the script as it uses the browser.* namespace... Chrome insists on chrome.* Roll Eyes I also modified o_e_l_e_o's .css to fix the order of the buttons and also get the "Report as:" text into the correct place.

As always... this is "AT YOUR OWN RISK"... I accept no responsibility if you get banned for spamming mods! Tongue

1. Download the latest browser-polyfill.js from here, put it in the same directory as the other files from OP: https://github.com/mozilla/webextension-polyfill/releases
(HINT: click on the unpkg.com link... ie. for 0.4.0: https://unpkg.com/[email protected]/dist/)

2. Modify the manifest.json to reference the browser-polyfill.js BEFORE the other .js files and to fix the "version" error (apparently Chrome doesn't like the 'b' in 0.1b Roll Eyes):
Code:
{

  "manifest_version": 2,
  "name": "BCT Helper",
  "version": "0.1.1",

  "description": "Adds some automation for bitcointalk.org.",

  "content_scripts": [
    {
      "matches": [ "*://bitcointalk.org/*" ],
      "js": [ "browser-polyfill.js","bct-content.js" ],
      "css": [ "bct-content.css" ],
      "run_at": "document_idle"
    }
  ],

  "background":
  {
    "scripts": ["browser-polyfill.js","bct-background.js"]
  },
 
  "permissions": [
    "tabs"
  ]
}

3. Enable "Developer Mode" in Chrome Extension settings

4. Then click "Load unpacked" in Chrome Extension settings, browse to the directory where you placed all the files and click "Select Folder"


PROTIP: If you find that when you try to report a post, it opens a new tab in the background, but then doesn't appear to actually submit the report... try reading the OP again carefully Wink




NOTE: This fix is ONLY needed if you use o_e_l_e_o's .css!!!
This is the fix for .css to put the "Report as:" text on the right with the buttons.
Code:
div.post {
    border-left: 4px transparent solid;
}

div.post.post-wait {
    opacity: 0.5;
}

div.post.post-error {
    border-left: 4px red solid;
}

div.post.post-success {
    border-left: 4px yellow solid;
}

.bct-report-button-container {
    float: right;
    margin-top: 10px;
    margin-bottom: 40px;
}

.bct-report-input {
    float: right;
    margin-right: 4px;
    height: 16px;
}

.bct-report-button, .bct-report-button:hover {
    float: right;
    background-image: linear-gradient(#375F82, #88A6C0);
    border: 1px solid black;
    margin-left: 4px;
    padding: 3px 5px 3px 5px;
    transform: none;
    color: #ffffff;
}

.bct-report-button:hover {
    cursor: pointer;
}


NOTE: This fix is ONLY needed if you use o_e_l_e_o's .css!!!
This is the fix for the "copy from:" and "move to:" buttons and text boxes being in the wrong order

You need to replace the code in bct_content.js with the following:
Code:
console.log("BCT-CONTENT initialized");
console.log("Page: " + window.location.href);
console.log("Referrer: " + document.referrer);

function process_background_message(message, sender, send_response) {
    browser.runtime.onMessage.removeListener(process_background_message);
    console.log("Content script received background message: " + JSON.stringify(message));
    if (message.action == "bct-tab-open-report" || message.action == "bct-tab-submit-report") {
        if (message.comment !== undefined) {
            document.getElementsByName("comment")[0].value = message.comment;
        }
        document.getElementsByName("comment")[0].focus();
        message.result = "OK";
    }
    if (message.action == "bct-tab-submit-report") {
        // mod report counts as post/PM for throttling - add a delay
        setTimeout(() => {
            send_response(message);
            // Uncomment the next line to allow reports to be submitted automatically
            //document.querySelector("input[type=submit][value=Submit]").click();
        }, 5000);
    } else {
        send_response(message);
    }
    // this is needed to make the sender wait for a response
    return true;
}

function report_post(post_container, thread_id, post_id, report_comment, auto_submit) {
    post_container.classList.add("post-wait");

    let event_detail = {
        event_id: (Math.random().toString(36) + '000000000000000000').slice(2, 18),
        action_name: "bct-report",
        action_url: "https://bitcointalk.org/index.php?action=reporttm;topic=" + thread_id + ";msg=" + post_id,
        action_payload: { post_id: post_id, comment: report_comment, auto: auto_submit }
    };

    browser.runtime.sendMessage(event_detail)
        .then((message_response) => {
            //console.log("message_response: " + JSON.stringify(message_response));
            console.log("message_response size: " + JSON.stringify(message_response).length);
            post_container.classList.remove("post-wait", "post-error", "post-success");
            post_container.classList.add("post-success");
        })
        .catch((error) => {
            console.log("Data request failed:");
            console.log(error);
            post_container.classList.remove("post-wait", "post-error", "post-success");
            post_container.classList.add("post-error");
        })
    ;
   
}

function extract_ids_from_url(post_url) {
    let url_parts = post_url.split("#msg");
    let post_id = url_parts[1];
    let thread_id = url_parts[0].split(".msg")[0].split("?topic=")[1];
    return [thread_id, post_id];
}

function create_button(post_container, button_title, report_comment, text_field, auto_submit) {
    let button = document.createElement("button");
    button.className = "bct-report-button";
    button.innerText = button_title;
    button.title = report_comment;
    button.addEventListener("click", (e) => {
        e.preventDefault();
        if (text_field) {
            if (text_field.value.trim()) {
                report_comment += " " + text_field.value.trim();
            } else {
                alert("Required value missing");
                return;
            }
        }
        report_post(post_container, post_container.thread_id, post_container.post_id, report_comment, auto_submit);
    });
    return button;
}

function create_span(text) {
    let span = document.createElement("span");
    span.innerText = text;
    return span;
}

function create_text_field(hint) {
    let text_field = document.createElement("input");
    text_field.className = "bct-report-input";
    text_field.type = "text";
    text_field.placeholder = hint;
    return text_field;
}

// inject the buttons into each message
document.querySelectorAll("div.post").forEach(post_container => {
    // Try to determine thread ID and post ID
    let link_object = null;
    if (post_container.parentNode.classList.contains("td_headerandpost")) {
        // Thread view
        // post -> td.td_headerandpost -> table ... -> div#subject_123456
        link_object = post_container.parentNode.firstElementChild.querySelector("div[id^='subject_'] a");
    } else {
        // Other views: patrol, user's post history, user's thread history
        let post_url_start = "https://bitcointalk.org/index.php?topic=";
        // post -> td -> tr -> tbody -> tr ... -> a[href contains #msg123456]
        link_object = post_container.parentNode.parentNode.parentNode.firstElementChild.querySelector("a[href^='" + post_url_start + "'][href*='#msg']");
    }
    if (link_object) {
        [post_container.thread_id, post_container.post_id] = extract_ids_from_url(link_object.getAttribute("href"));
        if (post_container.thread_id && post_container.post_id) {
            let button_container = document.createElement("div");
            button_container.className = "bct-report-button-container";
            post_container.appendChild(button_container);
            button_container.appendChild(create_span("Report as: "));
            button_container.appendChild(create_button(post_container, "zero value", "zero-value shitpost", null, true));
            button_container.appendChild(create_button(post_container, "multi post", "two or more consecutive posts in 24h", null, true));
            button_container.appendChild(create_button(post_container, "cross spam", "spamming their service across multiple threads - please check post history", null, true));
            button_container.appendChild(create_button(post_container, "non-english", "non-English post on English board", null, true));
            let url_field = create_text_field("URL of the original");
            button_container.appendChild(url_field);
            button_container.appendChild(create_button(post_container, "copy from:", "copy-paste from:", url_field, true));
            let board_field = create_text_field("correct board name");
            button_container.appendChild(board_field);
            button_container.appendChild(create_button(post_container, "move to:", "wrong board, should be in", board_field, true));
        } else {
            console.log("Found div.post and post URL but couldn't determine thread/post ID.");
        }
    } else {
        console.log("Found div.post but couldn't find post URL.");       
    }
});

if (window.location.href.startsWith("https://bitcointalk.org/index.php?action=reporttm")) {
    document.getElementsByName("comment")[0].style.width = "80%";
    browser.runtime.onMessage.addListener(process_background_message);
}
if (window.location.href.startsWith("https://bitcointalk.org/index.php?board=")) {
    if (document.referrer &&
        document.referrer.startsWith("https://bitcointalk.org/index.php?action=reporttm") &&
        document.referrer.endsWith(";a") // after automatic submission
    ) {
        console.log("Attempting to close this tab...");
        browser.runtime.sendMessage({ action_name: "close-this-tab" });
    }
}
legendary
Activity: 2268
Merit: 18711
Definitely worth a bump.

I've found I can reduce the delay of 5000 on line 21 of bct-content.js to 4000 without running in to any problems.

I'll also post my edited .css file in case anyone wants to steal my appearance. Essentially I made the buttons all right aligned so they aren't directly in my eye line when reading, and made them blend in more with the general theme. Appearances and code below. If you do right align everything you will also need to switch the order of the "button_container.appendChild(url_field)" and "button_container.appendChild(create_button)" lines in bct-content.js, so the text boxes still appear in the correct place.



Code:
div.post {
    border-left: 4px transparent solid;
}

div.post.post-wait {
    opacity: 0.5;
}

div.post.post-error {
    border-left: 4px red solid;
}

div.post.post-success {
    border-left: 4px yellow solid;
}

.bct-report-button-container {
    margin-top: 10px;
    margin-bottom: 40px;
}

.bct-report-input {
    float: right;
    margin-right: 4px;
    height: 16px;
}

.bct-report-button, .bct-report-button:hover {
    float: right;
    background-image: linear-gradient(#375F82, #88A6C0);
    border: 1px solid black;
    margin-left: 4px;
    padding: 3px 5px 3px 5px;
    transform: none;
    color: #ffffff;
}

.bct-report-button:hover {
    cursor: pointer;
}
legendary
Activity: 3654
Merit: 8909
https://bpip.org
I'm kinda torn whether I should bump this. It's like giving a box of matches to a toddler.

Speaking of which, I recently earned a bad report by accidentally clicking one of these buttons on a post I didn't intend to report (it was Quickseller's post but as I said - total accident). So be careful. You get a few seconds to close the report tab before it gets submitted.
legendary
Activity: 2394
Merit: 6581
be constructive or S.T.F.U
 wish it was posted a long time ago, but better late than never, will try it and let you know if i find any issues. thanks Grin
legendary
Activity: 3654
Merit: 8909
https://bpip.org
Nice code, thanks Smiley
Is it possible to ask theymos to just implement it into the code?
And only activate it for those who e.g. has at least 1,000 good reports?
It would be awesome Smiley

There is a petition for a similar feature: https://bitcointalksearch.org/topic/suggestion-expansion-of-the-report-feature-to-benefit-both-mods-reporters-5103283

Perhaps if we pester theymos long enough he'll give in.
hero member
Activity: 1442
Merit: 629
Vires in Numeris
Nice code, thanks Smiley
Is it possible to ask theymos to just implement it into the code?
And only activate it for those who e.g. has at least 1,000 good reports?
It would be awesome Smiley
legendary
Activity: 2310
Merit: 2073
~snip~

It's super suchmoon!


For a long time I did not understand why I do not have an extended interface window. My mistake was in one lost character from the code field. I added your hack to Russian locale
legendary
Activity: 3654
Merit: 8909
https://bpip.org
Yeah, I've added a couple of buttons for myself. Changed in the bct-content.js file.
I'm not a programmer and figured it out pretty quickly. Other examples are definitely welcome though!

Awesome. Another one I use often is "multi posting" AKA "two or more consecutive posts in 24h". I'll post a small update later today with some other stuff than may come in useful.



I updated bct-content.js and bct-content.css with some small tweaks. CreateButton function has changed so if you had any customizations these will need to be slightly updated like this:

Code:
           button_container.appendChild(create_button(post_container, "button name", "comment to submit", null or text box - see below, true));

I added mouse-over on buttons to show the comment text that will be submitted, and added an option to pass a text field which allows to do something like this:

Loading...
Edited 2020-11-30 to fix a broken image

So in this example if you click the "copy from:" button the actual comment that gets submitted would be "copy-paste from: http://some.url/link", i.e. concatenates predefined text with what you enter in the box.
Pages:
Jump to: