FA Instant Nuker

Adds nuke buttons to instantly nuke all submissions or messages

  1. // ==UserScript==
  2. // @name FA Instant Nuker
  3. // @namespace Violentmonkey Scripts
  4. // @match *://*.furaffinity.net/*
  5. // @require https://update.greatest.deepsurf.us/scripts/525666/1549449/Furaffinity-Prototype-Extensions.js
  6. // @require https://update.greatest.deepsurf.us/scripts/483952/1549453/Furaffinity-Request-Helper.js
  7. // @require https://update.greatest.deepsurf.us/scripts/485827/1549457/Furaffinity-Match-List.js
  8. // @require https://update.greatest.deepsurf.us/scripts/475041/1550020/Furaffinity-Custom-Settings.js
  9. // @grant GM_info
  10. // @version 1.0.2
  11. // @author Midori Dragon
  12. // @description Adds nuke buttons to instantly nuke all submissions or messages
  13. // @icon https://www.furaffinity.net/themes/beta/img/banners/fa_logo.png
  14. // @license MIT
  15. // @homepageURL https://greatest.deepsurf.us/scripts/527752-fa-instant-nuker
  16. // @supportURL https://greatest.deepsurf.us/scripts/527752-fa-instant-nuker/feedback
  17. // ==/UserScript==
  18. // jshint esversion: 8
  19. (() => {
  20. "use strict";
  21. var NukeIconOptions, MessageType, __webpack_require__ = {
  22. d: (exports, definition) => {
  23. for (var key in definition) if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
  24. enumerable: true,
  25. get: definition[key]
  26. });
  27. },
  28. o: (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
  29. };
  30. __webpack_require__.d({}, {
  31. uL: () => requestHelper,
  32. j_: () => selectNukeIconSetting
  33. });
  34. !function(NukeIconOptions) {
  35. NukeIconOptions.Red = "red";
  36. NukeIconOptions.White = "white";
  37. }(NukeIconOptions || (NukeIconOptions = {}));
  38. !function(MessageType) {
  39. MessageType[MessageType.None = 0] = "None";
  40. MessageType[MessageType.Watches = 1] = "Watches";
  41. MessageType[MessageType.JournalComments = 2] = "JournalComments";
  42. MessageType[MessageType.Shouts = 3] = "Shouts";
  43. MessageType[MessageType.Favorites = 4] = "Favorites";
  44. MessageType[MessageType.Journals = 5] = "Journals";
  45. MessageType[MessageType.Submission = 6] = "Submission";
  46. MessageType[MessageType.All = 7] = "All";
  47. }(MessageType || (MessageType = {}));
  48. class WhiteNukeSVG {
  49. static get Svg() {
  50. return '<svg class="svg-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" style="fill: rgba(0, 0, 0, 1);transform: ;msFilter:;"><path d="M9.912 8.531 7.121 3.877a.501.501 0 0 0-.704-.166 9.982 9.982 0 0 0-4.396 7.604.505.505 0 0 0 .497.528l5.421.09a4.042 4.042 0 0 1 1.973-3.402zm8.109-4.51a.504.504 0 0 0-.729.151L14.499 8.83a4.03 4.03 0 0 1 1.546 3.112l5.419-.09a.507.507 0 0 0 .499-.53 9.986 9.986 0 0 0-3.942-7.301zm-4.067 11.511a4.015 4.015 0 0 1-1.962.526 4.016 4.016 0 0 1-1.963-.526l-2.642 4.755a.5.5 0 0 0 .207.692A9.948 9.948 0 0 0 11.992 22a9.94 9.94 0 0 0 4.396-1.021.5.5 0 0 0 .207-.692l-2.641-4.755z"></path><circle cx="12" cy="12" r="3"></circle></svg>';
  51. }
  52. }
  53. var __awaiter = function(thisArg, _arguments, P, generator) {
  54. return new (P || (P = Promise))((function(resolve, reject) {
  55. function fulfilled(value) {
  56. try {
  57. step(generator.next(value));
  58. } catch (e) {
  59. reject(e);
  60. }
  61. }
  62. function rejected(value) {
  63. try {
  64. step(generator.throw(value));
  65. } catch (e) {
  66. reject(e);
  67. }
  68. }
  69. function step(result) {
  70. result.done ? resolve(result.value) : function adopt(value) {
  71. return value instanceof P ? value : new P((function(resolve) {
  72. resolve(value);
  73. }));
  74. }(result.value).then(fulfilled, rejected);
  75. }
  76. step((generator = generator.apply(thisArg, _arguments || [])).next());
  77. }));
  78. };
  79. class NukeButton {
  80. constructor(messageType) {
  81. this.messageType = messageType;
  82. this.nukeButton = document.createElement("button");
  83. this.nukeButton.classList.add("in-button", "standard", "nuke");
  84. if (selectNukeIconSetting.value === NukeIconOptions.Red) {
  85. const nukeIcon = document.createElement("div");
  86. nukeIcon.classList.add("in-button-icon", "sprite-nuke");
  87. nukeIcon.style.margin = "0px";
  88. this.nukeButton.appendChild(nukeIcon);
  89. } else if (selectNukeIconSetting.value === NukeIconOptions.White) this.nukeButton.innerHTML = WhiteNukeSVG.Svg;
  90. this.nukeButton.addEventListener("click", (() => {
  91. this.nuke();
  92. }));
  93. }
  94. nuke() {
  95. return __awaiter(this, void 0, void 0, (function*() {
  96. switch (this.messageType) {
  97. case MessageType.Watches:
  98. yield requestHelper.PersonalUserRequests.MessageRequests.NewMessages.Watches.nukeMessages();
  99. break;
  100.  
  101. case MessageType.JournalComments:
  102. yield requestHelper.PersonalUserRequests.MessageRequests.NewMessages.JournalComments.nukeMessages();
  103. break;
  104.  
  105. case MessageType.Shouts:
  106. yield requestHelper.PersonalUserRequests.MessageRequests.NewMessages.Shouts.nukeMessages();
  107. break;
  108.  
  109. case MessageType.Favorites:
  110. yield requestHelper.PersonalUserRequests.MessageRequests.NewMessages.Favorites.nukeMessages();
  111. break;
  112.  
  113. case MessageType.Journals:
  114. yield requestHelper.PersonalUserRequests.MessageRequests.NewMessages.Journals.nukeMessages();
  115. break;
  116.  
  117. case MessageType.Submission:
  118. yield requestHelper.PersonalUserRequests.MessageRequests.NewSubmissions.nukeSubmissions();
  119. }
  120. }));
  121. }
  122. }
  123. class MessageNuker {
  124. constructor() {
  125. const messagesForm = document.getElementById("messages-form"), messageSections = null == messagesForm ? void 0 : messagesForm.querySelectorAll('section[class="section_container"][id*="messages-"]');
  126. if (null != messageSections) for (const section of Array.from(messageSections)) {
  127. const sectionType = this.getSectionTypeFromElement(section);
  128. if (sectionType === MessageType.None) continue;
  129. const nukeButton = new NukeButton(sectionType), sectionControls = section.querySelector('div[class*="section_controls"]');
  130. if (sectionControls) sectionControls.appendChild(nukeButton.nukeButton);
  131. }
  132. }
  133. getSectionTypeFromElement(section) {
  134. switch (section.id.trimStart("messages-")) {
  135. default:
  136. return MessageType.None;
  137.  
  138. case "watches":
  139. return MessageType.Watches;
  140.  
  141. case "comments-journal":
  142. return MessageType.JournalComments;
  143.  
  144. case "shouts":
  145. return MessageType.Shouts;
  146.  
  147. case "favorites":
  148. return MessageType.Favorites;
  149.  
  150. case "journals":
  151. return MessageType.Journals;
  152. }
  153. }
  154. }
  155. class SubmissionNuker {
  156. constructor() {
  157. const standardPage = document.getElementById("standardpage"), actionsSection = null == standardPage ? void 0 : standardPage.querySelectorAll('section[class*="actions-section"]');
  158. if (null != actionsSection) for (const section of Array.from(actionsSection)) {
  159. const sectionOptions = section.querySelector('div[class*="section-options"]');
  160. if (null == sectionOptions) continue;
  161. const nukeButton = new NukeButton(MessageType.Submission);
  162. sectionOptions.appendChild(nukeButton.nukeButton);
  163. }
  164. }
  165. }
  166. const customSettings = new window.FACustomSettings("Midori's Script Settings", "FA Instant Nuker Settings"), selectNukeIconSetting = customSettings.newSetting(window.FASettingType.Option, "Select Nuke Icon");
  167. selectNukeIconSetting.description = "Select the Nuke Icon to use for the Nuke Button.";
  168. selectNukeIconSetting.options = {
  169. [NukeIconOptions.Red]: "Red Nuke Icon",
  170. [NukeIconOptions.White]: "White Nuke Icon"
  171. };
  172. selectNukeIconSetting.defaultValue = NukeIconOptions.Red;
  173. customSettings.loadSettings();
  174. const requestHelper = new window.FARequestHelper(2);
  175. if (customSettings.isFeatureEnabled) {
  176. const matchListSubmissions = new window.FAMatchList(customSettings);
  177. matchListSubmissions.matches = [ "msg/submissions" ];
  178. matchListSubmissions.runInIFrame = false;
  179. if (matchListSubmissions.hasMatch) new SubmissionNuker;
  180. const matchListMessages = new window.FAMatchList(customSettings);
  181. matchListMessages.matches = [ "msg/others" ];
  182. matchListMessages.runInIFrame = false;
  183. if (matchListMessages.hasMatch) new MessageNuker;
  184. }
  185. })();