Report to news

Allow you to make a quick report to the news by pressing the "News report" link at the top-right.

目前為 2015-11-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Report to news
// @description Allow you to make a quick report to the news by pressing the "News report" link at the top-right.
// @namespace   HF
// @author      Hash G.
// @include     *hackforums.net*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @version     1
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_xmlhttpRequest
// ==/UserScript==

window.onload = function() {
	postkey = $("head > script:contains('<!--')").html();
	postkey = postkey.split("\n")[10];
	postkey = postkey.split('"')[1];
	console.log(postkey);

	$("body").append("<div id='popup_news' style='background-color: rgb(51, 51, 51); bottom: auto; border: 1px solid rgb(0, 0, 0); height: 30%; left: 182px; margin: 0px; max-height: 95%; max-width: 95%; opacity: 1; overflow: auto; padding: 0px; position: fixed; right: auto; top: 128px; width: 75%; z-index: 999; display: none;'><h4>Briefly describe the event: </h4><input id='step1' type='text'><br><h4>Any important links: </h4><input id='step2' type='text'><br><br><br><button class='bitButton' id='sendNews' onclick='sendNews()'>Send!</button> <button class='bitButton' id='closeNews'>Close</button><br><br><span id='status'></span></div>");
	$(".links").append(" | <a href='#' id='showNews'>News report</a>");

	$("#sendNews").on("click", function() {
		$("#status").html("Sending...");
		step1 = $("#step1").val();
		step2 = $("#step2").val();
		report = "[b][color=#ffde98]Briefly describe the event: [/color][/b] " + step1 + "\n[b][color=#ffde98]Any important links: [/color][/b]" + step2;
		$.post("http://hackforums.net/newreply.php", {
			"my_post_key": postkey,
			"action": "do_newreply",
			"tid": "4992602",
			"message": report
		},
			function (data, status) {
				console.log("Sent: " + status);
				$("#status").html("Sent!");
				setTimeout(function() { $("#popup_news").css("display", "none"); }, 350);
		});
	});

	$("#showNews").on("click", function() {
		$("#popup_news").css("display", "block");
	});
	
	$("#closeNews").on("click", function() {
		$("#popup_news").css("display", "none");
	});
};