Advertisement
Guest User

Untitled

a guest
Aug 14th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. var waitForAndExecute = function(waitForFun, execFun) {
  2. (function() {
  3. function waitForAndExecute(waitForFun, execFun) {
  4. if (!waitForFun()) {
  5. setTimeout(function() {
  6. waitForAndExecute(waitForFun, execFun);
  7. }, 100);
  8.  
  9. return;
  10. }
  11.  
  12. execFun();
  13. };
  14.  
  15. waitForAndExecute(waitForFun, execFun);
  16. })();
  17. };
  18.  
  19. var clickWhenAvailable = function(query, callback) {
  20. waitForAndExecute(
  21. function() {
  22. return document.querySelector(query);
  23. },
  24. function() {
  25. document.querySelector(query).click();
  26.  
  27. callback();
  28. }
  29. );
  30. };
  31.  
  32. var setValueWhenAvailable = function(query, value, callback) {
  33. waitForAndExecute(
  34. function() {
  35. return document.querySelector(query);
  36. },
  37. function() {
  38. document.querySelector(query).value = value;
  39.  
  40. callback();
  41. }
  42. );
  43. };
  44.  
  45. var yourAccountName = document.querySelector('.Header__userpic a').title;
  46. var toAccountName = window.location.pathname.split('/')[1].substring(1);
  47.  
  48. document.querySelector('[href="/@' + yourAccountName + '"]').click();
  49.  
  50. clickWhenAvailable('[href="/@' + yourAccountName + '"]', function() {
  51. clickWhenAvailable('[href="/@' + yourAccountName + '/transfers"]', function() {
  52. clickWhenAvailable('.UserWallet__balance:nth-child(4) a', function() {
  53. clickWhenAvailable('.UserWallet__balance:nth-child(4) li a', function() {
  54. setValueWhenAvailable('[role="dialog"] input', toAccountName, function() {
  55. setTimeout(function() {
  56. document.querySelectorAll('[role="dialog"] input')[1].focus();
  57. }, 500);
  58. });
  59. });
  60. });
  61. });
  62. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement