// ==UserScript==// @name Download File Under Timestamp Name// @namespace pcgia// @description Adds a button to download a file and gives it a timestamp name, instead of the original name or the hash// @match https://8chan.moe/*/res/*// @match https://8chan.se/*/res/*// @version 1// @grant none// @run-at document-end// @author Starknight// @version 1.0.0// ==/UserScript==constuploadCells=Array.from(document.querySelectorAll('figure.uploadCell'));for(letcellofuploadCells){consthideFileButton=cell.querySelector('span.hideFileButton');if(!hideFileButton){console.error('I can\'t find the hide button, ignoring this cell.');continue;}constoriginalNameLink=cell.querySelector('a.originalNameLink');if(!originalNameLink||!originalNameLink.href||0===originalNameLink.href.length){console.error('I can\'t grasp the original file name, ignoring this cell.');continue;}constserverHref=originalNameLink.href;consthrefSplit=serverHref.split('.');if(2>hrefSplit.length){console.error('The file name is quite unexpected, ignoring this cell.');continue;}constserverExt='.'+hrefSplit.pop();constdownloadButton=document.createElement('a');downloadButton.href=originalNameLink.href;downloadButton.download=Date.now()+serverExt;downloadButton.dataset.fileExt=serverExt;downloadButton.classList.add('nameLink','coloredIcon','pcgiaTimestampDownloadButton');downloadButton.title='Download file';hideFileButton.after(downloadButton);}constthisCss=`.uploadCell > details .pcgiaTimestampDownloadButton::after { content: '\\e04E';}.uploadCell > details .pcgiaTimestampDownloadButton { display: inline-block; margin-left: 0.125em;}`;constthisStyle=document.createElement('style');thisStyle.innerText=thisCss;document.head.appendChild(thisStyle);
Warning
LINK
You are about to visit a link which has been flagged with the above content warnings. Do you wish to continue?