RaaW2

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 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/4195/19952/RaaW2.js

  1. // ==UserScript==
  2. // @name RaaW2
  3. // @version 2.5.6
  4. // @namespace RaaW2
  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 +=
  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> <a id='reportUserToAdmin' style='color:black;' href='#'> | ADMIN </a>";
  58. }
  59. else {
  60. newToolbar.innerHTML += "<a id='downvoteComment' style='color:black;' href='#'> DOWNVOTE ALL</a> <a id='upvoteComment' style='color:black;' href='#'> | UPVOTE ALL</a> "; <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. $('#reportUserToAdmin').on('click',function(e){
  90. reportToAdmin();
  91. });
  92.  
  93. }
  94.  
  95. function buildReportArray() {
  96. if (commentPage.length == 0) {
  97. var threads;
  98. threads = $('#siteTable').find('.thing');
  99. for (i = 0; i < threads.length; i++) {
  100. reportID.push(threads[i].getAttribute('data-fullname'));
  101. }
  102. }
  103. else if (commentPage.length != 0) {
  104. var threads;
  105. threads = $('.commentarea').find('.thing');
  106. for (i = 0; i < threads.length; i++) {
  107. reportID.push(threads[i].getAttribute('data-fullname'));
  108. }
  109. }
  110. }
  111.  
  112. function reportItem(index, num) {
  113. if(num == 3) {var fullname = topicIDs[index];}
  114. else{var fullname = commentIDs[index];}
  115. $.post('http://www.reddit.com/api/report', {'id': fullname, 'uh': modHash});
  116. }
  117.  
  118.  
  119. function theDownvoter() {
  120. if (parsedPage[3] == 'user'){
  121. var items = $('#siteTable').find('.arrow.down');
  122. Array.prototype.forEach.call(items, function(el, i){
  123. setTimeout(function(){
  124. el.click();
  125. },100 + ( i * 400 ));
  126. });
  127. return false;
  128. }
  129. else {
  130. if (commentPage.length == 0) {
  131. var items = $('#siteTable').find('.arrow.down');
  132. Array.prototype.forEach.call(items, function(el, i){
  133. setTimeout(function(){
  134. el.click();
  135. },100 + ( i * 400 ));
  136. });
  137. return false;
  138. }
  139. else {
  140. var items = $('.commentarea').find('.arrow.down');
  141. Array.prototype.forEach.call(items, function(el, i){
  142. setTimeout(function(){
  143. el.click();
  144. },100 + ( i * 400 ));
  145. });
  146. return false;
  147. }
  148. }
  149. }
  150.  
  151. function theUpvoter() {
  152. if (parsedPage[3] == 'user'){
  153. var items = $('#siteTable').find('.arrow.up');
  154. Array.prototype.forEach.call(items, function(el, i){
  155. setTimeout(function(){
  156. el.click();
  157. },100 + ( i * 400 ));
  158. });
  159. return false;
  160. }
  161. else {
  162. if (commentPage.length == 0) {
  163. var items = $('#siteTable').find('.arrow.up');
  164. Array.prototype.forEach.call(items, function(el, i){
  165. setTimeout(function(){
  166. el.click();
  167. },100 + ( i * 400 ));
  168. });
  169. return false;
  170. }
  171. else {
  172. var items = $('.commentarea').find('.arrow.up');
  173. Array.prototype.forEach.call(items, function(el, i){
  174. setTimeout(function(){
  175. el.click();
  176. },100 + ( i * 400 ));
  177. });
  178. return false;
  179. }
  180. }
  181. }
  182.  
  183. function reportToSpam(){
  184. var username = $(document).find('.pagename.selected').text();
  185. window.open('http://www.reddit.com/r/spam/submit?title=overview for '+ username + '&resubmit=true&url=http://www.reddit.com/user/' + username + "?");
  186. }
  187.  
  188. function analyzeSend(){
  189. var username = $(document).find('.pagename.selected').text();
  190. window.open('http://www.reddit.com/message/compose/?to=analyzereddit&subject=analyze&message='+ username);
  191. }
  192.  
  193. function botwatchmanSend(){
  194. var username = $(document).find('.pagename.selected').text();
  195. window.open('http://www.reddit.com/r/botwatchman/submit?title=overview for '+ username + '&url=http://www.reddit.com/user/' + username);
  196. }
  197. function composeNew(){
  198. window.open('http://www.reddit.com/message/compose/');
  199. }
  200.  
  201. if (document.documentElement.lang === 'np') {
  202. document.documentElement.lang = 'en-us';
  203. }
  204.  
  205. function reportToAdmin(){
  206. var username = $(document).find('.pagename.selected').text();
  207. window.open('http://www.reddit.com/message/compose/?to=/r/reddit.com&message='+ username);
  208. }
  209.  
  210. //disable .np
  211.  
  212. document.body.classList.add('subscriber');
  213.  
  214. delete_function = function(thread_root) {
  215. 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)"]');
  216. for(var i=0; i < elmnts.length; i++) {
  217. setTimeout(
  218. (function(_elmnt) {
  219. return function() {
  220. var event = document.createEvent('UIEvents');
  221. event.initUIEvent('click', true, true, window, 1);
  222. _elmnt.dispatchEvent(event);
  223. }}
  224. )(elmnts[i]), 1500*i); // 1.5s timeout prevents overloading reddit.
  225. };
  226. }
  227.  
  228. //source reveal (creesch)
  229.  
  230. $('.comments-page .comment .flat-list.buttons').each(function () { // this targets each flat-list belonging to comments on a comment page.
  231. $(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
  232. });
  233.  
  234. $('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.
  235. var $this = $(this), // We posisbly want to reuse $(this), it is cleaner to define jquery objects you want to reuse.
  236. $parentThing = $this.closest('.thing'),
  237. thingId = $parentThing.attr('data-fullname'); // we need an id to throw at the api, luckily it is is present in the html.
  238. if($parentThing.find('#box-' + thingId).length) { // Lets see if we already did do this before.
  239. $parentThing.find('#box-' + thingId).toggle(); // we did, toggle
  240. } else { // we did not, grab the info.
  241. $.getJSON('/api/info.json?id=' + thingId, function () { // lets do an ajax call to grab the info we need.
  242. console.log("success"); // you can remove this, basically lets you know a json call is done.
  243. })
  244. .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.
  245. var commentBody = data.data.children[0].data.body; // json is basically an object.
  246. var commentSourceBox = '<textarea style="display:block" rows="10" cols="50">'+ commentBody + '</textarea>'; // build the source box.
  247. $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.
  248. });
  249. }
  250. });
  251.  
  252.  
  253. //nuke (djimbob)
  254. delete_function = function(thread_root) {
  255. 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)"]');
  256. for(var i=0; i < elmnts.length; i++) {
  257. setTimeout(
  258. (function(_elmnt) {
  259. return function() {
  260. var event = document.createEvent('UIEvents');
  261. event.initUIEvent('click', true, true, window, 1);
  262. _elmnt.dispatchEvent(event);
  263. }}
  264. )(elmnts[i]), 1500*i); // 1.5s timeout prevents overloading reddit.
  265. };
  266. }
  267. if(document.querySelector('body.moderator')){ // only execute if you are a moderator
  268. var nuke_button = new Array();
  269. var divels = document.querySelectorAll('div.noncollapsed');
  270. var comment_ids = new Array();
  271. var use_image = false;
  272. // create img DOM element to clone
  273. if(use_image) {
  274. try {
  275. var img_element = document.createElement('img');
  276. img_element.setAttribute('alt', 'Nuke!');
  277. img_element.setAttribute('src', chrome.extension.getURL('nuke.png'));
  278. } catch(e) {
  279. use_image = false;
  280. }
  281. }
  282. for (var i = 0; i < divels.length; i++) {
  283. var author_link = divels[i].querySelector('p.tagline>a.author,p.tagline>span.author,p.tagline>em');
  284. // p.tagline>a.author is normal comment;
  285. // some author deleted comments seem to have either
  286. // p.tagline>span.author or p.tagline>em
  287. comment_ids[i] = divels[i].getAttribute('data-fullname');
  288. // console.log(i + ':' + comment_ids);
  289. if(author_link) {
  290. // create link DOM element with img inside link
  291. nuke_button[i] = document.createElement('a')
  292. nuke_button[i].setAttribute('href', 'javascript:void(0)');
  293. nuke_button[i].setAttribute('title', 'Nuke!');
  294. nuke_button[i].setAttribute('id', 'nuke_'+i);
  295. if(use_image) {
  296. nuke_button[i].appendChild(img_element.cloneNode(true));
  297. } else {
  298. nuke_button[i].innerHTML= "[Nuke]";
  299. }
  300. // append after the author's name
  301. author_link.parentNode.insertBefore(nuke_button[i], author_link.nextSibling);
  302. // Add listener for click; using IIFE to function with _i as value of i when created; not when click
  303. nuke_button[i].addEventListener('click',
  304. (function(_i) {
  305. return function() {
  306. var continue_thread = divels[_i].querySelectorAll('span.morecomments>a');
  307. var comment_str = " comments?";
  308. if(continue_thread.length > 0) {
  309. comment_str = "+ comments (more after expanding collapsed threads; there will be a pause before the first deletion to retrieve more comments)?";
  310. }
  311. var delete_button = divels[_i].querySelectorAll('form input[value="removed"]~span.option.error a.yes,a[onclick^="return big_mod_action($(this), -1)"]');
  312. // form input[value="removed"]~span.option.error a.yes -- finds the yes for normal deleting comments.
  313. // a.pretty-button.neutral finds the 'remove' button for flagged comments
  314. if (confirm("Are you sure you want to nuke the following " + delete_button.length + comment_str)) {
  315. for (var indx=0; indx < continue_thread.length; indx++) {
  316. var elmnt = continue_thread[indx];
  317. setTimeout(
  318. function() {
  319. var event = document.createEvent('UIEvents');
  320. event.initUIEvent('click', true, true, window, 1);
  321. elmnt.dispatchEvent(event);
  322. }, 2000*indx); // wait two seconds before each ajax call before clicking each "load more comments"
  323. }
  324. if(indx > 0) {
  325. setTimeout(function() {delete_function(comment_ids[_i])},
  326. 2000*(indx + 2)); // wait 4s after last ajax "load more comments"
  327. } else {
  328. delete_function(comment_ids[_i]); // call immediately if not "load more comments"
  329. }
  330. }
  331. }
  332. }
  333. )(i)); // end of IIFE (immediately invoked function expression)
  334. }
  335. }
  336. }
  337.  
  338. //linkswapping
  339.  
  340. document.addEventListener("DOMContentLoaded", replaceLinks, false );
  341.  
  342. if( document.readyState === "complete" ) {
  343. replaceLinks();
  344. }
  345.  
  346. function replaceLinks() {
  347. Array.forEach( document.links, function(a) {
  348. a.href = a.href.replace( "https://i.imgur.com", "http://imgur.com");
  349. a.href = a.href.replace( "https://imgur.com", "http://imgur.com");
  350. });
  351. }
  352.  
  353. generateToolbar(), getHash(),buildReportArray(), doStuff();

QingJ © 2025

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