Skip to content

Instantly share code, notes, and snippets.

@vulpesfoxnik
Forked from dashdanw/gist:26f941f303553cb2822d
Last active August 29, 2015 14:06
Show Gist options
  • Save vulpesfoxnik/07f8a6f69c9ef504256c to your computer and use it in GitHub Desktop.
Save vulpesfoxnik/07f8a6f69c9ef504256c to your computer and use it in GitHub Desktop.
// ==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