Hack Forums - Notify xadamxk with reports

Adds buttons to post to 'quick report' them; sends PM of reported post.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name            Hack Forums - Notify xadamxk with reports
// @namespace       Snorlax
// @description     Adds buttons to post to 'quick report' them; sends PM of reported post.
// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @grant           GM_getValue
// @grant           GM_setValue
// @grant           GM_xmlhttpRequest
// @include         *hackforums.net/showthread.php*
// @version         1.0
// ==/UserScript==

username = "xadamxk";
my_post_key = unsafeWindow.my_post_key;

$(".post_management_buttons").prepend("<a href='javascript:void(0)' class='bitButton quickReport'>S Report</a>");

$(".quickReport").on("click", function() {
    message = "[url=http://hackforums.net/" + encodeURIComponent($(this).parentsUntil("table[id*='post_']").parent().find("a[href*='showthread.php?tid=']").attr("href")) + "]This post needs moderation[/url]";
    if(confirm("Are you sure you wish to report this?") == true) {
        console.log("Sending PM to " + username + " with message: " + message);
        GM_xmlhttpRequest({
            method: "POST",
            url: "http://hackforums.net/private.php",
            data: "my_post_key=" + my_post_key + "&to=" + username + "&bcc=&subject=Quick%20Report&message_new=" + message + "&message=" + message + "&options%5Bsignature%5D=1&options%5Bsavecopy%5D=1&options%5Breadreceipt%5D=1&action=do_send&pmid=&do=&submit=Send+Message",
            headers: {
                "Content-Type": "application/x-www-form-urlencoded",
                "Referer": "http://www.hackforums.net/private.php?action=send"
            }
        });
    }
});