-
-
Save vulpesfoxnik/07f8a6f69c9ef504256c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name furaffinity.net | |
// @namespace furaffinity-downloadLinks | |
// @description furaffinity.net addons | |
// @include furaffinity.net* | |
// @version 0.1b | |
// ==/UserScript== | |
var myDocument | |
(function () { | |
'use strict'; | |
var submissions = Array.prototype.slice.call(document.querySelectorAll('#messagecenter-submissions a[href^="/view/"]')), | |
outputElement = document.createElement('DIV'); | |
outputElement.id = 'downloadOutput'; | |
window.document.body.insertBefore(outputElement, window.document.body.firstChild); | |
function processNode(nodeIndex) { | |
var lookAheadReq = new XMLHttpRequest(); | |
function loaded(event){ | |
var outputSection = outputElement.appendChild(window.document.createElement('div')), | |
outputLink, | |
downloadLink, | |
head = submissions[nodeIndex].parentElement.parentElement.parentElement, | |
workName = head.querySelector('span[title]').textContent, | |
artist = head.querySelector('a[href^="/user/"]').textContent, | |
doc = document.implementation.createHTMLDocument('test'); | |
doc.documentElement.innerHTML = lookAheadReq.responseText; | |
downloadLink = doc.documentElement.querySelector('a[href^="//d.facdn.net/art/"]').href; | |
outputSection.id = 'download-container-' + nodeIndex; | |
outputSection.textContent = (nodeIndex + 1) + ". "; | |
outputLink = outputSection.appendChild(window.document.createElement('a')); | |
outputLink.textContent = workName + ' by ' + artist; | |
outputLink.href = downloadLink; | |
window.setTimeout(function () {processNode(nodeIndex+1);}, 1000); // To prevent Server hammering | |
} | |
if (submissions.length > nodeIndex) { | |
lookAheadReq.open("GET", submissions[nodeIndex].href); | |
lookAheadReq.addEventListener('load', loaded, false); | |
lookAheadReq.send(); | |
} | |
} | |
processNode(0); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment