MCBBS Report

快速水龙头举报

  1. // ==UserScript==
  2. // @name MCBBS Report
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description 快速水龙头举报
  6. // @author CaveNightingale
  7. // @match https://www.mcbbs.net/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. //是否在一个新的标签页内举报
  12. const newtab = true;
  13. //所使用的水龙头图片的地址
  14. //可以像这样的base64直接把整张图片弄进来,也可以外链
  15. const imageurl = "data:image/ico;base64,AAABAAEAEBAQAAAAAAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAND/AOhGOgA/6OIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAiAAAAAAAAACIAAAAAAAAAIgAAAAAAAAAAAAAAAAAAABEAAAAzMQABEQAAARMzEBERARERETMxERAAAAARMzEAAAAAAAETMwAAAAAAABEwAAAAAAAAERAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/+QAA//kAAP/5AAD/8AAA+DAAAPAgAAAAAAAAAAEAAAADAADwDwAA/B8AAPwfAAD8HwAA/j8AAP4/AADwBwAA";
  16.  
  17. (() => {
  18. 'use strict';
  19. const disallow = {//已被禁言的用户不应再被举报
  20. "https://www.mcbbs.net/home.php?mod=spacecp&ac=usergroup&gid=4": "禁止发言",
  21. "https://www.mcbbs.net/home.php?mod=spacecp&ac=usergroup&gid=5": "禁止访问",
  22. "https://www.mcbbs.net/home.php?mod=spacecp&ac=usergroup&gid=6": "禁止IP",
  23. "https://www.mcbbs.net/home.php?mod=spacecp&ac=usergroup&gid=9": "Herobrine"
  24. };
  25.  
  26. function byId(id){
  27. return document.getElementById(id);
  28. }
  29.  
  30. function isEditing(){//判断是否在编辑举报
  31. let args = window.location.search.substring(1).split("&");
  32. return args.indexOf("mod=post") >= 0 && args.indexOf("action=edit") >= 0 && args.indexOf("tid=557610") >= 0;
  33. }
  34.  
  35. function findEditableReportInThisPage(){//找到一个未处理的举报帖
  36. let btns = byId("postlist").getElementsByClassName("editp");
  37. if(btns.length == 0){
  38. return null;
  39. }
  40. let post = btns[0].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;//编辑键向上走8层
  41. if(byId(post.id.replace("post", "ratelog")) == null){//判断举报是否被处理是依据是否有评分
  42. return btns[0].href;
  43. }
  44. return null;
  45. }
  46.  
  47. function getUserGroup(){
  48. for(let em of document.getElementsByClassName("xg1")){
  49. if(em.outerHTML == "<em class=\"xg1\">用户组&nbsp;&nbsp;</em>"){
  50. return em.parentElement.getElementsByTagName("a")[0].href;
  51. }
  52. }
  53. return null;
  54. }
  55.  
  56. let uhd = byId("uhd");
  57. let myuid = byId("user_info").children[0].children[0].href.substring("https://www.mcbbs.net/home.php?mod=space&uid=".length);
  58. if(uhd){//在个人主页
  59. let p = uhd.children[0].children[0];
  60. if(p.children.length >= 2){
  61. let target = document.createElement("li");
  62. let a = document.createElement("a");
  63. target.appendChild(a);
  64. a.className = "cavenightingale_report";
  65. a.href = `https://www.mcbbs.net/forum.php?mod=viewthread&tid=557610&page=1&authorid=${myuid}`;
  66. if(newtab){
  67. a.target = "_blank";
  68. }
  69. let link = document.createTextNode("举报水龙头");
  70. a.appendChild(link);
  71. p.appendChild(target);
  72. a.onclick = function(){
  73. localStorage["cavenightingale:report_context"] =//这段内容来自版规
  74. `违规者用户名(必填):${uhd.children[1].children[1].innerHTML.replace("\n","")}
  75. 违规者个人资料链接(必填):${uhd.children[1].children[2].children[0].innerHTML}
  76. 违规类型(必填):[签名档违规/头像违规/用户名违规/水龙头,可多选]水龙头
  77. 违规截图(可选, 水龙头举报无需附图):`;
  78. let group = getUserGroup();
  79. if(disallow[group]){
  80. localStorage["cavenightingale:report_confirm"] = `您正在尝试举报一名${disallow[group]}的用户!\n继续举报可能违规\n点击“确定”继续举报`;
  81. }
  82. }
  83. }
  84. }
  85.  
  86. if(localStorage["cavenightingale:report_context"]){
  87. if(isEditing()){//在编辑举报
  88. let context = byId("e_textarea");
  89. let report = localStorage["cavenightingale:report_context"];
  90. if(localStorage["cavenightingale:report_confirm"] ? confirm(localStorage["cavenightingale:report_confirm"]) : true){
  91. if(context.value.indexOf(report.split("\n")[0]) >= 0 ? confirm("您对此用户的上一个举报尚未被处理!\n继续举报可能违规\n点击“确定”继续举报") : true){
  92. context.value += "\n\n" + report;
  93. byId("e_iframe").contentDocument.body.innerHTML += ("\n\n" + report).replace(/\n/g, "<br>");
  94. }
  95. }
  96. delete localStorage["cavenightingale:report_context"];
  97. delete localStorage["cavenightingale:report_confirm"];
  98. }
  99.  
  100. let url = String(window.location);
  101. if(url == `https://www.mcbbs.net/forum.php?mod=viewthread&tid=557610&page=1&authorid=${myuid}`){//在举报专用帖下
  102. let last = findEditableReportInThisPage();
  103. if(last != null){
  104. window.location = last;
  105. }else{
  106. window.location = "https://www.mcbbs.net/thread-557610-1-1.html";
  107. }
  108. }else if(url == "https://www.mcbbs.net/thread-557610-1-1.html"){
  109. if(localStorage["cavenightingale:report_confirm"] ? confirm(localStorage["cavenightingale:report_confirm"]) : true){
  110. let context = byId("fastpostmessage");
  111. context.value = localStorage["cavenightingale:report_context"];
  112. context.focus();
  113. }
  114. delete localStorage["cavenightingale:report_context"];
  115. delete localStorage["cavenightingale:report_confirm"];
  116. }
  117. }
  118.  
  119. let style = document.createElement("style");
  120. style.innerHTML =
  121. `.cavenightingale_report{
  122. background: url(${imageurl}) no-repeat 1px 2px!important;
  123. background-size: 16px!important;
  124. }`;
  125. document.body.appendChild(style);
  126. })();