Hack Forums - Notify xadamxk with reports

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

(I already have a user style manager, let me install it!)

// ==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"
            }
        });
    }
});