Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Discord Attachment Copier
- // @version 1.6
- // @description try to take over the world!
- // @author TurretBot
- // @match *.discord.com/channels/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=discord.com
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- function getsub(id) {
- var attatchments="",att=document.getElementById("message-accessories-"+id).querySelectorAll("a"),subt=document.getElementById("message-content-"+id).querySelectorAll('span'),i=0;
- for (i=0;i<att.length;i++) {
- if ((att[i]+"").includes("cdn.discord")) {attatchments=attatchments.concat(att[i]+"\n")};
- }
- for (i=0;i<subt.length;i++) {
- if (subt[i].className.includes("attachmentLink")) {attatchments=attatchments.concat(subt[i].getAttribute('href')+"\n")};
- }
- //clear dupes (audio has two hrefs w same link)
- attatchments=attatchments.split("\n").filter((item, i, allItems) => {return i === allItems.indexOf(item);}).join("\n");
- return attatchments+document.getElementById("message-content-"+id).innerText.replaceAll("\`\`\`","");
- };
- function ButtonClickAction (zEvent) {
- zEvent.target.innerHTML=getsub(zEvent.target.id);
- }
- //edited_f9f2ca
- //attachmentLink wrapper_f61d60 interactive
- var mo = new MutationObserver(function(muts) {
- muts.forEach(function(mut) {
- Array.prototype.forEach.call(mut.addedNodes, function(node) {
- if (node instanceof HTMLElement) {
- Array.prototype.forEach.call(node.querySelectorAll('time'), function(img) {
- //https://stackoverflow.com/questions/6480082/add-a-javascript-button-using-greasemonkey-or-tampermonkey
- if (img.class="edited_f9f2ca") {img.innerHTML="";}
- var zNode=document.createElement('textarea');
- zNode.rows=1
- zNode.placeholder="Click for submission text"
- zNode.id=img.id.replace("message-timestamp-","");
- zNode.addEventListener(
- "click", ButtonClickAction, false
- );
- img.appendChild(zNode);
- });
- }
- });
- });
- });
- mo.observe(document.body, {childList: true, subtree: true});
- })();
Advertisement
Add Comment
Please, Sign In to add comment