Last active
August 14, 2016 10:56
-
-
Save lantto/367b8cbf0ab1542a99510034d4a61c67 to your computer and use it in GitHub Desktop.
Donate Directly
This file contains 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
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