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-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Report to news
  3. // @description Allow you to make a quick report to the news by pressing the "News report" link at the top-right.
  4. // @namespace HF
  5. // @author Hash G.
  6. // @include *hackforums.net*
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
  8. // @version 1.01
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_xmlhttpRequest
  12. // ==/UserScript==
  13.  
  14. window.onload = function() {
  15. postkey = $("head > script:contains('<!--')").html();
  16. postkey = postkey.split("\n")[10];
  17. postkey = postkey.split('"')[1];
  18. console.log(postkey);
  19. event = "";
  20. link = "";
  21. if (!location.href.match(/index.php/i) || !location.href.match(/hackforums.net/i)) {
  22. link = document.location.href.replace(/\#$/, '');
  23. name = $("span.largetext > strong:nth-child(1) > span").html();
  24. uid = document.location.href.substr(52).replace(/\#$/, '');
  25. event = "[url=http://hackforums.net/member.php?action=profile&uid=" + uid + "][color=#EFEFEF][b]" + name + "[/b][/color][/url]";
  26.  
  27. if (location.href.match(/myawards.php/i)) {
  28. name = $("#content a[href*='action=profile&uid=']").html();
  29. uid = document.location.href.substr(39).replace(/\#$/, '');
  30. award = $("tbody tr").last().children().html().substr(8).split("</strong>")[0];
  31. imageaward = $("img[src*='uploads/awards']:last").attr("src");
  32. event = "[url=http://hackforums.net/member.php?action=profile&uid=" + uid + "][color=#EFEFEF][b]" + name + "[/b][/color][/url] got the " + award + " award [img]http://hackforums.net" + imageaward + "[/img]";
  33. }
  34. if (location.href.match(/showthread.php/i)) {
  35. event = "";
  36. }
  37. }
  38.  
  39. $("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;'><span style='float: right; margin-right: 1%; margin-top: 0.5%;'><a href='http://hackforums.net/showthread.php?tid=4992602&action=lastpost' target='_blank'>News thread</a></span><br><h4>Briefly describe the event: </h4><input id='step1' style='width: 70%' type='text' value='"+event+"'><br><h4>Any important links: </h4><input id='step2' style='width: 70%' type='text' value="+link+"><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>");
  40. $(".links").append(" | <a href='#' id='showNews'>News report</a>");
  41.  
  42. $("#sendNews").on("click", function() {
  43. $("#status").html("Sending...");
  44. step1 = $("#step1").val();
  45. step2 = $("#step2").val();
  46. report = "[b][color=#ffde98]Briefly describe the event: [/color][/b] " + step1 + "\n[b][color=#ffde98]Any important links: [/color][/b] " + step2;
  47. $.post("http://hackforums.net/newreply.php", {
  48. "my_post_key": postkey,
  49. "action": "do_newreply",
  50. "tid": "4992602",
  51. "message": report
  52. },
  53. function (data, status) {
  54. console.log("Sent: " + status);
  55. $("#status").html("Sent!");
  56. setTimeout(function() { $("#popup_news").css("display", "none"); $("#status").html(""); }, 350);
  57. });
  58. });
  59.  
  60. $("#showNews").on("click", function() {
  61. $("#popup_news").css("display", "block");
  62. });
  63. $("#closeNews").on("click", function() {
  64. $("#popup_news").css("display", "none");
  65. });
  66. };