Guest User

REDDIT OVERWRITE SCRIPT

a guest
Sep 17th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.20 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Reddit Overwrite
  3. // @namespace Reddit
  4. // @description This script overwrites your Reddit comment history to help prevent people from stalking and doxing. It also helps prevent mods from profiling and censoring. Normally Reddit only sets a delete flag when you delete, so this more efficiently protects your privacy. To use it, login to Reddit, click your username, go to the comments tab, and click on the new OVERWRITE button. This script works MUCH more efficiently if you use RES and scroll down to the earliest comment you wish to overwrite.
  5. // @include https://*.reddit.com/*
  6. // @include http://*.reddit.com/*
  7. // @version 1.4
  8. // @run-at document-start
  9. // ==/UserScript==
  10.  
  11.  
  12. unsafeWindow.to_delete = [];
  13. unsafeWindow.num_user_comments = 0;
  14. unsafeWindow.deleted = 0;
  15. unsafeWindow.span = '';
  16. unsafeWindow.user = '';
  17.  
  18.  
  19. unsafeWindow.delete_comment = function(thing_id, from_delete_all)
  20. {
  21. try{
  22. var thing = document.querySelector("input[name='thing_id'][value='" + thing_id + "']");
  23.  
  24.  
  25. var status = thing.parentNode.querySelector("div.usertext-edit > div.bottom-area > div.usertext-buttons > span.status").innerHTML;
  26.  
  27. var error = false;
  28. if ((status.indexOf("error") != -1) || (status.indexOf("submitting") != -1)){
  29. error = true;
  30. } else {
  31. // var del_form = thing.parentNode.parentNode.querySelector("ul.buttons > li > form.del-button");
  32. // unsafeWindow.toggle(del_form.querySelector("span.main > a"));
  33. // del_form.querySelector("span.error > a.yes").click();
  34. unsafeWindow.deleted++;
  35. }
  36.  
  37. if (from_delete_all){
  38. if (unsafeWindow.to_delete.length != 0)
  39. {
  40. unsafeWindow.span.innerHTML = "OVERWRITING COMMENT " + (unsafeWindow.deleted + 1) + " OF " + unsafeWindow.num_user_comments;
  41. var next_thing_id = unsafeWindow.to_delete.pop();
  42. unsafeWindow.setTimeout(unsafeWindow.overwrite_comment, 2000, next_thing_id, from_delete_all);
  43. }
  44. else
  45. {
  46. if (unsafeWindow.num_user_comments - unsafeWindow.deleted != 0){
  47. unsafeWindow.num_user_comments = unsafeWindow.num_user_comments - unsafeWindow.deleted;
  48. UpdateDeleteAllSpan();
  49. unsafeWindow.span.innerHTML = "<span>Failed to overwrite " + unsafeWindow.num_user_comments + " comments</span><br>" + unsafeWindow.span.innerHTML;
  50. } else
  51. unsafeWindow.span.style.display = 'none';
  52.  
  53. }
  54. } else {
  55. if (error)
  56. alert("Failed to overwrite your comment. Overwrite aborted.");
  57. else
  58. unsafeWindow.num_user_comments--;
  59. UpdateDeleteAllSpan();
  60. }
  61. return (error ? -1 : 0);
  62. }catch(er){
  63. alert(er);
  64. if (from_delete_all) unsafeWindow.location.reload();
  65. return -99;
  66. }
  67. }
  68.  
  69. unsafeWindow.overwrite_comment = function(thing_id, from_delete_all)
  70. {
  71. try{
  72. var edit_form = document.querySelector("input[name='thing_id'][value='" + thing_id + "']").parentNode;
  73.  
  74. edit_form.querySelector("div.usertext-edit > div.bottom-area > div.usertext-buttons > button.cancel").click();
  75.  
  76.  
  77. var edit_btn = edit_form.parentNode.querySelector("ul > li > a.edit-usertext");
  78. if (edit_btn) edit_btn.click();
  79. var edit_textbox = edit_form.querySelector("div.usertext-edit > div > textarea");
  80. var repl_str = '';
  81. var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz><.-,+!#$%^&*();:[]~";
  82. // for(var x = 0; x < edit_textbox.value.length; x++){
  83. // if (edit_textbox.value.substr(x,1) == '\n'){
  84. // repl_str += '\n';
  85. // }else{
  86. // var rnum = Math.floor(Math.random() * chars.length);
  87. // repl_str += chars.charAt(rnum, 1);
  88. // }
  89. // }
  90. var sumting = '^^^^^^^^^^^^^^^^' + Math.random();
  91. var sumtingtr = sumting.substring(0,22);
  92.  
  93. edit_textbox.value = "[deleted] \n " + sumtingtr + " \n > [What is this?](https://pastebin.com/64GuVi2F)";
  94.  
  95. edit_form.querySelector("div.usertext-edit > div.bottom-area > div.usertext-buttons > button.save").click();
  96. unsafeWindow.setTimeout(unsafeWindow.delete_comment, 2000, thing_id, from_delete_all);
  97. return 0;
  98. }catch(e){
  99. alert("Error interacting with overwrite form: " + e);
  100. return -99;
  101. }
  102. };
  103.  
  104.  
  105. unsafeWindow.delete_all = function()
  106. {
  107. try{
  108. unsafeWindow.num_user_comments = 0;
  109. unsafeWindow.deleted = 0;
  110. unsafeWindow.to_delete = [];
  111. var comments = document.querySelectorAll("a.author");
  112.  
  113. for (var i = 0; i < comments.length; i++)
  114. {
  115. if (comments[i].innerHTML != unsafeWindow.user) continue;
  116. var thing_id = comments[i].parentNode.parentNode.querySelector("form.usertext > input[name='thing_id']").value;
  117. if (unsafeWindow.to_delete.indexOf(thing_id) == -1){
  118. unsafeWindow.to_delete.push(thing_id);
  119. unsafeWindow.num_user_comments++;
  120. }
  121. }
  122.  
  123. unsafeWindow.span.innerHTML = "TRYING TO Overwrite COMMENT 1 OF " + unsafeWindow.num_user_comments;
  124. var next_thing_id = unsafeWindow.to_delete.pop();
  125. unsafeWindow.overwrite_comment(next_thing_id, true);
  126. } catch(e){
  127. alert("YOU ARE MOST LIKELY NOT ON THE COMMENTS TAB! /n/n Error trying to delete all your comments.\nError: " + e + " Stack:" + e.stack);
  128. unsafeWindow.location.reload()
  129. }
  130. };
  131.  
  132. function add_delete_links(ev)
  133. {
  134. unsafeWindow.user = document.querySelector("span.user > a:not(.login-required)").innerHTML;
  135. if (!unsafeWindow.user){return;}
  136. var comments = document.querySelectorAll("a.author");
  137. unsafeWindow.num_user_comments = 0;
  138. for (var i = 0; i < comments.length; i++)
  139. {
  140. if (comments[i].innerHTML != unsafeWindow.user) continue;
  141. try{
  142. var main_parent = comments[i].parentNode.parentNode;
  143. var thing_id = main_parent.querySelector("form > input[name='thing_id']").value;
  144. var list = main_parent.querySelector("ul.flat-list");
  145. if (list.querySelector("li.secure_delete")) continue;
  146. unsafeWindow.num_user_comments++;
  147.  
  148. var addedlink = document.createElement("li");
  149. addedlink.setAttribute('class', 'secure_delete');
  150. var dlink = document.createElement("a");
  151. dlink.setAttribute('class','bylink secure_delete');
  152. dlink.setAttribute('onClick','javascript:var ret = overwrite_comment("' + thing_id + '", false);');
  153. dlink.setAttribute('href', 'javascript:void(0)');
  154. // dlink.appendChild(document.createTextNode('SECURE DELETE'));
  155. addedlink.appendChild(dlink);
  156. main_parent.querySelector("ul.flat-list").appendChild(addedlink);
  157. }catch(e){}
  158. }
  159.  
  160. unsafeWindow.span = document.createElement("span");
  161. unsafeWindow.span.setAttribute('class', 'nextprev secure_delete_all');
  162. UpdateDeleteAllSpan();
  163.  
  164. }
  165.  
  166. function UpdateDeleteAllSpan()
  167. {
  168. if (unsafeWindow.num_user_comments){
  169. unsafeWindow.span.innerHTML = "";
  170. var dlink = document.createElement("a");
  171. dlink.setAttribute('class','bylink');
  172. dlink.setAttribute('onClick','javascript:return delete_all()');
  173. dlink.setAttribute('href', 'javascript:void(0)');
  174. dlink.appendChild(document.createTextNode('OVERWRITE ALL visible comment(s) on this page - MAKE SURE YOU ARE ON THE COMMENTS TAB. It is also HIGHLY recommended to use Reddit Enhancement Suite with the Never Ending Reddit feature to extend the comments as far down as possible.'));
  175. unsafeWindow.span.appendChild(dlink);
  176. document.querySelector("div.content").insertBefore(unsafeWindow.span,document.querySelector("div.content").firstChild);
  177. } else if (unsafeWindow.span != null) {
  178. unsafeWindow.span.style.display = 'none';
  179. }
  180. }
  181.  
  182. window.addEventListener("DOMContentLoaded",add_delete_links, false);
Add Comment
Please, Sign In to add comment