RaaW

Reddit as a Weapon script. Parts and idea by /u/noeatnosleep, enhanced by /u/enim, /u/creesch, and /u/djimbob. RaaW adds links for page-wide voting and reporting. It adds a 'report to /r/spam' link, an 'analyze user submission domains' link, and a 'report to /r/botwatchman' link to userpages. RaaW disables the np. domain. RaaW Adds a 'show source' button for comments. DISCLIAMER: Use this at your own risk. If the report button is misued, you could be shadowbanned.

当前为 2014-10-04 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/4195/19949/RaaW.js

  1. // ==UserScript==
  2. // @name RaaW
  3. // @version 2.5.5
  4. // @namespace RaaW
  5. // @description Reddit as a Weapon script. Parts and idea by /u/noeatnosleep, enhanced by /u/enim, /u/creesch, and /u/djimbob. RaaW adds links for page-wide voting and reporting. It adds a 'report to /r/spam' link, an 'analyze user submission domains' link, and a 'report to /r/botwatchman' link to userpages. RaaW disables the np. domain. RaaW Adds a 'show source' button for comments. DISCLIAMER: Use this at your own risk. If the report button is misued, you could be shadowbanned.
  6. // @include http://www.reddit.com/user/*
  7. // @include http://www.reddit.com/r/*
  8. // @include http://*reddit.com/*
  9. // @include https://www.reddit.com/user/*
  10. // @include https://www.reddit.com/r/*
  11. // @include https://*reddit.com/*
  12. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
  13. // ==/UserScript==
  14.  
  15. this.$ = this.jQuery = jQuery.noConflict(true);
  16.  
  17. var currentPage = document.URL;
  18. var parsedPage = currentPage.split('/');
  19. var modHash = null;
  20. var currentUser = null;
  21. var subreddit = null;
  22. var commentIDs = [];
  23. var topicIDs = [];
  24. var subredditList = [];
  25. var reportID = [];
  26.  
  27. var commentPage;
  28. commentPage = document.getElementsByClassName('comment');
  29.  
  30. function getHash(callback) {
  31. var query = new XMLHttpRequest();
  32. query.onreadystatechange = function () {
  33. if (query.readyState == 4) {
  34. var info = JSON.parse(query.responseText);
  35. modHash = info.data.modhash;
  36. callback();
  37. }
  38. }
  39. query.open('GET', 'http://www.reddit.com/api/me.json', true);
  40. query.send(null);
  41. }
  42.  
  43. function generateToolbar () {
  44. $(document).find('#header')[0].style.paddingTop='18px';
  45. var newToolbar = document.createElement("div");
  46. newToolbar.id = "newToolbar";
  47. document.body.insertBefore(newToolbar,document.body.firstChild);
  48. var subredditbar = document.getElementById('sr-header-area');
  49. newToolbar.style.cssText="color:black;background-color:'#f0f0f0';border-bottom:1px black solid;font-family:verdana, arial, helvetica, sans-serif;font-size:90%;height:12px;padding:3px 0px 3px 6px;text-transform:uppercase;width:100%;z-index:+999999;position:fixed;top:0;";
  50. newToolbar.style.backgroundColor='#f0f0f0';
  51. newToolbar.style.paddingLeft = '6px';
  52. newToolbar.style.paddingTop = '3px';
  53. newToolbar.style.paddingBottom = '3px';
  54. newToolbar.style.top='0px';
  55. newToolbar.innerHTML += "<a id='downvoteComment' style='color:black;' href='#'> DOWNVOTE ALL</a> <a id='upvoteComment' style='color:black;' href='#'> | UPVOTE ALL</a> ";
  56. if (parsedPage[3] == 'user'){
  57. newToolbar.innerHTML += "<a id=reportComment style='color:black;' href='#'> | REPORT ALL</a> <a id='botwatchmanSend' style='color:black;' href='#'> | /R/BOTWATCHMAN </a> <a id='analyzeSend' style='color:black;' href='#'> | ANALYZE </a> <a id='reportUserToSpam' style='color:black;' href='#'> | /R/SPAM </a>";
  58. }
  59. else {
  60. newToolbar.innerHTML += " <a id='composeNew' style='color:black;' href='#'> | COMPOSE </a>";
  61. }
  62.  
  63. }
  64.  
  65.  
  66. function doStuff() {
  67. $('#reportComment').on('click',function(e) {
  68. for(var i = 0; i < reportID.length; i++) {reportItem(i, 3);}
  69. alert('All items on this page were reported.');
  70. });
  71. $('#downvoteComment').on('click',function(e){
  72. theDownvoter();
  73. });
  74. $('#upvoteComment').on('click',function(e){
  75. theUpvoter();
  76. });
  77. $('#reportUserToSpam').on('click',function(e){
  78. reportToSpam();
  79. });
  80. $('#analyzeSend').on('click',function(e){
  81. analyzeSend();
  82. });
  83. $('#botwatchmanSend').on('click',function(e){
  84. botwatchmanSend();
  85. });
  86. $('#composeNew').on('click',function(e){
  87. composeNew();
  88. });
  89. }
  90.  
  91. function buildReportArray() {
  92. if (commentPage.length == 0) {
  93. var threads;
  94. threads = $('#siteTable').find('.thing');
  95. for (i = 0; i < threads.length; i++) {
  96. reportID.push(threads[i].getAttribute('data-fullname'));
  97. }
  98. }
  99. else if (commentPage.length != 0) {
  100. var threads;
  101. threads = $('.commentarea').find('.thing');
  102. for (i = 0; i < threads.length; i++) {
  103. reportID.push(threads[i].getAttribute('data-fullname'));
  104. }
  105. }
  106. }
  107.  
  108. function reportItem(index, num) {
  109. if(num == 3) {var fullname = topicIDs[index];}
  110. else{var fullname = commentIDs[index];}
  111. $.post('http://www.reddit.com/api/report', {'id': fullname, 'uh': modHash});
  112. }
  113.  
  114.  
  115. function theDownvoter() {
  116. if (parsedPage[3] == 'user'){
  117. var items = $('#siteTable').find('.arrow.down');
  118. Array.prototype.forEach.call(items, function(el, i){
  119. setTimeout(function(){
  120. el.click();
  121. },100 + ( i * 400 ));
  122. });
  123. return false;
  124. }
  125. else {
  126. if (commentPage.length == 0) {
  127. var items = $('#siteTable').find('.arrow.down');
  128. Array.prototype.forEach.call(items, function(el, i){
  129. setTimeout(function(){
  130. el.click();
  131. },100 + ( i * 400 ));
  132. });
  133. return false;
  134. }
  135. else {
  136. var items = $('.commentarea').find('.arrow.down');
  137. Array.prototype.forEach.call(items, function(el, i){
  138. setTimeout(function(){
  139. el.click();
  140. },100 + ( i * 400 ));
  141. });
  142. return false;
  143. }
  144. }
  145. }
  146.  
  147. function theUpvoter() {
  148. if (parsedPage[3] == 'user'){
  149. var items = $('#siteTable').find('.arrow.up');
  150. Array.prototype.forEach.call(items, function(el, i){
  151. setTimeout(function(){
  152. el.click();
  153. },100 + ( i * 400 ));
  154. });
  155. return false;
  156. }
  157. else {
  158. if (commentPage.length == 0) {
  159. var items = $('#siteTable').find('.arrow.up');
  160. Array.prototype.forEach.call(items, function(el, i){
  161. setTimeout(function(){
  162. el.click();
  163. },100 + ( i * 400 ));
  164. });
  165. return false;
  166. }
  167. else {
  168. var items = $('.commentarea').find('.arrow.up');
  169. Array.prototype.forEach.call(items, function(el, i){
  170. setTimeout(function(){
  171. el.click();
  172. },100 + ( i * 400 ));
  173. });
  174. return false;
  175. }
  176. }
  177. }
  178.  
  179. function reportToSpam(){
  180. var username = $(document).find('.pagename.selected').text();
  181. window.open('http://www.reddit.com/r/spam/submit?title=overview for '+ username + '&resubmit=true&url=http://www.reddit.com/user/' + username + "?");
  182. }
  183.  
  184. function analyzeSend(){
  185. var username = $(document).find('.pagename.selected').text();
  186. window.open('http://www.reddit.com/message/compose/?to=analyzereddit&subject=analyze&message='+ username);
  187. }
  188.  
  189. function botwatchmanSend(){
  190. var username = $(document).find('.pagename.selected').text();
  191. window.open('http://www.reddit.com/r/botwatchman/submit?title=overview for '+ username + '&url=http://www.reddit.com/user/' + username);
  192. }
  193. function composeNew(){
  194. window.open('http://www.reddit.com/message/compose/');
  195. }
  196.  
  197. if (document.documentElement.lang === 'np') {
  198. document.documentElement.lang = 'en-us';
  199. }
  200.  
  201. //disable .np
  202.  
  203. document.body.classList.add('subscriber');
  204.  
  205. delete_function = function(thread_root) {
  206. var elmnts = document.getElementsByClassName('id-'+thread_root)[0].querySelectorAll('form input[value="removed"]~span.option.error a.yes,a[onclick^="return big_mod_action($(this), -1)"]');
  207. for(var i=0; i < elmnts.length; i++) {
  208. setTimeout(
  209. (function(_elmnt) {
  210. return function() {
  211. var event = document.createEvent('UIEvents');
  212. event.initUIEvent('click', true, true, window, 1);
  213. _elmnt.dispatchEvent(event);
  214. }}
  215. )(elmnts[i]), 1500*i); // 1.5s timeout prevents overloading reddit.
  216. };
  217. }
  218.  
  219. //source reveal (creesch)
  220.  
  221. $('.comments-page .comment .flat-list.buttons').each(function () { // this targets each flat-list belonging to comments on a comment page.
  222. $(this).append('<li><a class="view-source" href="javascript:void(0)">view source</a></li>'); // it then adds the view source button in the belonging function
  223. });
  224.  
  225. $('body').on('click', '.view-source', function () { // On clicking of the view source button we do what we want to do. Note that we start with body since that is a constant dom element. If you try to target added dom elements directly it will not work.
  226. var $this = $(this), // We posisbly want to reuse $(this), it is cleaner to define jquery objects you want to reuse.
  227. $parentThing = $this.closest('.thing'),
  228. thingId = $parentThing.attr('data-fullname'); // we need an id to throw at the api, luckily it is is present in the html.
  229. if($parentThing.find('#box-' + thingId).length) { // Lets see if we already did do this before.
  230. $parentThing.find('#box-' + thingId).toggle(); // we did, toggle
  231. } else { // we did not, grab the info.
  232. $.getJSON('/api/info.json?id=' + thingId, function () { // lets do an ajax call to grab the info we need.
  233. console.log("success"); // you can remove this, basically lets you know a json call is done.
  234. })
  235. .done(function (data) { // by doing the stuff we need to do in .done we make sure we have the data needed since ajax is async.
  236. var commentBody = data.data.children[0].data.body; // json is basically an object.
  237. var commentSourceBox = '<textarea style="display:block" rows="10" cols="50">'+ commentBody + '</textarea>'; // build the source box.
  238. $parentThing.find('.flat-list').first().before(commentSourceBox); // and add it to the .thing, note that I use .first() if I didn't do that it would add the source box for all child comments as well.
  239. });
  240. }
  241. });
  242.  
  243.  
  244. //nuke (djimbob)
  245. delete_function = function(thread_root) {
  246. var elmnts = document.getElementsByClassName('id-'+thread_root)[0].querySelectorAll('form input[value="removed"]~span.option.error a.yes,a[onclick^="return big_mod_action($(this), -1)"]');
  247. for(var i=0; i < elmnts.length; i++) {
  248. setTimeout(
  249. (function(_elmnt) {
  250. return function() {
  251. var event = document.createEvent('UIEvents');
  252. event.initUIEvent('click', true, true, window, 1);
  253. _elmnt.dispatchEvent(event);
  254. }}
  255. )(elmnts[i]), 1500*i); // 1.5s timeout prevents overloading reddit.
  256. };
  257. }
  258. if(document.querySelector('body.moderator')){ // only execute if you are a moderator
  259. var nuke_button = new Array();
  260. var divels = document.querySelectorAll('div.noncollapsed');
  261. var comment_ids = new Array();
  262. var use_image = false;
  263. // create img DOM element to clone
  264. if(use_image) {
  265. try {
  266. var img_element = document.createElement('img');
  267. img_element.setAttribute('alt', 'Nuke!');
  268. img_element.setAttribute('src', chrome.extension.getURL('nuke.png'));
  269. } catch(e) {
  270. use_image = false;
  271. }
  272. }
  273. for (var i = 0; i < divels.length; i++) {
  274. var author_link = divels[i].querySelector('p.tagline>a.author,p.tagline>span.author,p.tagline>em');
  275. // p.tagline>a.author is normal comment;
  276. // some author deleted comments seem to have either
  277. // p.tagline>span.author or p.tagline>em
  278. comment_ids[i] = divels[i].getAttribute('data-fullname');
  279. // console.log(i + ':' + comment_ids);
  280. if(author_link) {
  281. // create link DOM element with img inside link
  282. nuke_button[i] = document.createElement('a')
  283. nuke_button[i].setAttribute('href', 'javascript:void(0)');
  284. nuke_button[i].setAttribute('title', 'Nuke!');
  285. nuke_button[i].setAttribute('id', 'nuke_'+i);
  286. if(use_image) {
  287. nuke_button[i].appendChild(img_element.cloneNode(true));
  288. } else {
  289. nuke_button[i].innerHTML= "[Nuke]";
  290. }
  291. // append after the author's name
  292. author_link.parentNode.insertBefore(nuke_button[i], author_link.nextSibling);
  293. // Add listener for click; using IIFE to function with _i as value of i when created; not when click
  294. nuke_button[i].addEventListener('click',
  295. (function(_i) {
  296. return function() {
  297. var continue_thread = divels[_i].querySelectorAll('span.morecomments>a');
  298. var comment_str = " comments?";
  299. if(continue_thread.length > 0) {
  300. comment_str = "+ comments (more after expanding collapsed threads; there will be a pause before the first deletion to retrieve more comments)?";
  301. }
  302. var delete_button = divels[_i].querySelectorAll('form input[value="removed"]~span.option.error a.yes,a[onclick^="return big_mod_action($(this), -1)"]');
  303. // form input[value="removed"]~span.option.error a.yes -- finds the yes for normal deleting comments.
  304. // a.pretty-button.neutral finds the 'remove' button for flagged comments
  305. if (confirm("Are you sure you want to nuke the following " + delete_button.length + comment_str)) {
  306. for (var indx=0; indx < continue_thread.length; indx++) {
  307. var elmnt = continue_thread[indx];
  308. setTimeout(
  309. function() {
  310. var event = document.createEvent('UIEvents');
  311. event.initUIEvent('click', true, true, window, 1);
  312. elmnt.dispatchEvent(event);
  313. }, 2000*indx); // wait two seconds before each ajax call before clicking each "load more comments"
  314. }
  315. if(indx > 0) {
  316. setTimeout(function() {delete_function(comment_ids[_i])},
  317. 2000*(indx + 2)); // wait 4s after last ajax "load more comments"
  318. } else {
  319. delete_function(comment_ids[_i]); // call immediately if not "load more comments"
  320. }
  321. }
  322. }
  323. }
  324. )(i)); // end of IIFE (immediately invoked function expression)
  325. }
  326. }
  327. }
  328.  
  329. //linkswapping
  330.  
  331. document.addEventListener("DOMContentLoaded", replaceLinks, false );
  332.  
  333. if( document.readyState === "complete" ) {
  334. replaceLinks();
  335. }
  336.  
  337. function replaceLinks() {
  338. Array.forEach( document.links, function(a) {
  339. a.href = a.href.replace( "https://i.imgur.com", "http://imgur.com");
  340. a.href = a.href.replace( "https://imgur.com", "http://imgur.com");
  341. });
  342. }
  343.  
  344. generateToolbar(), getHash(),buildReportArray(), doStuff();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址