Skip to content

Instantly share code, notes, and snippets.

@lantto
Last active August 14, 2016 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lantto/367b8cbf0ab1542a99510034d4a61c67 to your computer and use it in GitHub Desktop.
Save lantto/367b8cbf0ab1542a99510034d4a61c67 to your computer and use it in GitHub Desktop.
Donate Directly
var waitForAndExecute = function(waitForFun, execFun) {
(function() {
function waitForAndExecute(waitForFun, execFun) {
if (!waitForFun()) {
setTimeout(function() {
waitForAndExecute(waitForFun, execFun);
}, 100);
return;
}
execFun();
};
waitForAndExecute(waitForFun, execFun);
})();
};
var clickWhenAvailable = function(query, callback) {
waitForAndExecute(
function() {
return document.querySelector(query);
},
function() {
document.querySelector(query).click();
callback();
}
);
};
var setValueWhenAvailable = function(query, value, callback) {
waitForAndExecute(
function() {
return document.querySelector(query);
},
function() {
document.querySelector(query).value = value;
callback();
}
);
};
var yourAccountName = document.querySelector('.Header__userpic a').title;
var toAccountName = window.location.pathname.split('/')[1].substring(1);
document.querySelector('[href="/@' + yourAccountName + '"]').click();
clickWhenAvailable('[href="/@' + yourAccountName + '"]', function() {
clickWhenAvailable('[href="/@' + yourAccountName + '/transfers"]', function() {
clickWhenAvailable('.UserWallet__balance:nth-child(4) a', function() {
clickWhenAvailable('.UserWallet__balance:nth-child(4) li a', function() {
setValueWhenAvailable('[role="dialog"] input', toAccountName, function() {
setTimeout(function() {
document.querySelectorAll('[role="dialog"] input')[1].focus();
}, 500);
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment