🏠 Home 

Discord Nitrolen V2: A Free Auto-Embedding Nitro script

Basically Free Nitro. Join my server for updates: https://discord.gg/kS7P7gRZcg

  1. // ==UserScript==
  2. // @name Discord Nitrolen V2: A Free Auto-Embedding Nitro script
  3. // @version 2.3
  4. // @description Basically Free Nitro. Join my server for updates: https://discord.gg/kS7P7gRZcg
  5. // @author ∫(Ace)³dx
  6. // @match https://discord.com/*
  7. // @grant GM.xmlHttpRequest
  8. // @grant GM.registerMenuCommand
  9. // @grant GM.getValue
  10. // @grant GM.setValue
  11. // @grant GM.addElement
  12. // @license MIT
  13. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  14. // @namespace https://greasyfork.org/users/449798
  15. // ==/UserScript==
  16. //V2.2 - Made the instructions more clear on removing a custom emoji.
  17. //V2.3 - Further made the instructions more clear on removing a custom emoji.
  18. (async window => {
  19. 'use strict';
  20. const replacementsKey = 'customReplacements';
  21. // Initialize custom replacements
  22. let customReplacements = await GM.getValue(replacementsKey, []);
  23. // Create a function to update the UI with current replacements
  24. function updateUI() {
  25. // Clear previous UI
  26. const existingUI = document.getElementById('custom-replacements-ui');
  27. if (existingUI) {
  28. existingUI.remove();
  29. }
  30. // Create UI elements
  31. const uiContainer = document.createElement('div');
  32. uiContainer.id = 'custom-replacements-ui';
  33. const header = document.createElement('h2');
  34. header.textContent = 'Custom Replacements';
  35. const replacementsList = document.createElement('ul');
  36. for (let i = 0; i < customReplacements.length; i++) {
  37. const replacement = customReplacements[i];
  38. const item = document.createElement('li');
  39. item.innerHTML = `
  40. <input class="pattern-input" type="text" value="${replacement.pattern.source}" placeholder="Enter pattern..." />
  41. ->
  42. <input class="url-input" type="text" value="${replacement.url}" placeholder="Enter URL..." />
  43. <button class="edit-button" data-index="${i}">${replacement.pattern.source}</button>
  44. <button class="remove-button" data-index="${i}">Remove</button>
  45. `;
  46. replacementsList.appendChild(item);
  47. }
  48. uiContainer.appendChild(header);
  49. uiContainer.appendChild(replacementsList);
  50. // Add UI to the page
  51. document.body.appendChild(uiContainer);
  52. // Add event listeners for editing and removing
  53. const editButtons = document.querySelectorAll('.edit-button');
  54. const removeButtons = document.querySelectorAll('.remove-button');
  55. editButtons.forEach(button => {
  56. button.addEventListener('click', handleEdit);
  57. });
  58. removeButtons.forEach(button => {
  59. button.addEventListener('click', handleRemove);
  60. });
  61. }
  62. // Function to open a prompt using SweetAlert2 for adding replacements
  63. async function openAddPrompt() {
  64. const { value: pattern } = await Swal.fire({
  65. title: 'Enter the input string to replace (e.g. :bigsob:):',
  66. input: 'text',
  67. inputPlaceholder: 'Enter the input...',
  68. });
  69. if (pattern) {
  70. const { value: url } = await Swal.fire({
  71. title: 'Enter the replacement URL (a reload is required after this):',
  72. input: 'text',
  73. inputPlaceholder: 'Enter the URL...',
  74. });
  75. if (url) {
  76. customReplacements.push({ pattern: new RegExp(pattern, 'g'), url });
  77. GM.setValue(replacementsKey, customReplacements).then(() => {
  78. updateUI();
  79. });
  80. }
  81. }
  82. }
  83. // Function to open a prompt using SweetAlert2 for editing replacements
  84. async function openEditPrompt(index) {
  85. const { value: newPattern } = await Swal.fire({
  86. title: 'Enter input string to be edited:',
  87. input: 'text',
  88. inputValue: '',
  89. });
  90. if (newPattern !== undefined) {
  91. const { value: newUrl } = await Swal.fire({
  92. title: 'Edit replacement URL (if you wish to remove it, enter the input string below) (a reload is required after this):',
  93. input: 'text',
  94. inputValue: '',
  95. });
  96. if (newUrl !== undefined) {
  97. customReplacements[index] = { pattern: new RegExp(newPattern, 'g'), url: newUrl };
  98. GM.setValue(replacementsKey, customReplacements).then(() => {
  99. updateUI();
  100. });
  101. }
  102. }
  103. }
  104. // Function to handle removing replacements
  105. async function handleRemove(event) {
  106. const index = event.target.getAttribute('data-index');
  107. customReplacements.splice(index, 1);
  108. GM.setValue(replacementsKey, customReplacements).then(() => {
  109. updateUI();
  110. });
  111. }
  112. // Create a menu command to open the prompt for adding replacements
  113. GM.registerMenuCommand('Add Custom Replacement', openAddPrompt);
  114. // Register a menu command for each edit button
  115. customReplacements.forEach((replacement, index) => {
  116. GM.registerMenuCommand(`Edit Existing Prompts`, () => {
  117. openEditPrompt(index);
  118. });
  119. });
  120. // Intercept XMLHttpRequest and apply replacements
  121. const originalOpen = XMLHttpRequest.prototype.open;
  122. XMLHttpRequest.prototype.open = function(method, url) {
  123. if ((method.toUpperCase() === 'POST' || method.toUpperCase() === 'PATCH') && /https:\/\/discord\.com\/api\/v9\/channels\/[^\/]+\/messages.*?/.test(url)) {
  124. const originalSend = this.send;
  125. this.send = function(data) {
  126. try {
  127. let newData = data;
  128. for (const replacement of customReplacements) {
  129. newData = newData.replace(/"content":"(.*?)"/g, (match, content) => {
  130. let modifiedContent = content.replace(replacement.pattern, replacement.url);
  131. return `"content":"${modifiedContent}"`;
  132. });
  133. }
  134. originalSend.call(this, newData);
  135. } catch (error) {
  136. console.error('Error modifying data:', error);
  137. originalSend.call(this, data);
  138. }
  139. };
  140. }
  141. originalOpen.apply(this, arguments);
  142. };
  143. // Update the UI with current replacements
  144. updateUI();
  145. })(window);