Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. chrome.extension.sendMessage({}, function(response) {
  2.     var readyStateCheckInterval = setInterval(function() {
  3.     if (document.readyState === "complete") {
  4.         clearInterval(readyStateCheckInterval);
  5.  
  6.  
  7.     if(window.location.hash=="#script") {
  8.    
  9.    
  10.     var oneKeyOnly = true;
  11.    
  12.    
  13.     function checkItem() {
  14.     var itemsArray = ["Apples", "Bananas", "Oranges", ];
  15.     var matchingItems = [];
  16.     var x = document.getElementsByClassName("item");
  17.     for(var y = 0; y < x.length; y++){
  18.         if(itemsArray.indexOf(x[y].getAttribute("data-name")) >= 0){
  19.             var id = x[y].getElementsByClassName("item-checkbox")[0].getAttribute("id");
  20.             matchingItems.push(id);
  21.         }
  22.     }
  23.     return matchingItems;
  24. }
  25.  
  26.  
  27. function randomIntFromInterval(min,max)
  28. {
  29.     return Math.floor(Math.random()*(max-min+1)+min);
  30. }
  31.  
  32. function clickButton(val)
  33. {
  34.     var buttons = document.getElementsByTagName('input');
  35.     for(var i = 0; i < buttons.length; i++)
  36.     {
  37.        if(buttons[i].type == 'submit' && buttons[i].value == val)
  38.        {
  39.            buttons[i].click();
  40.            console.log("Trying to withdraw!");
  41.            break;
  42.        }
  43.     }
  44. }
  45.  
  46. var result = checkItem();
  47. var lengthOfArray = result.length - 1;
  48.  
  49. if (oneKeyOnly == true) {
  50. var rand = randomIntFromInterval(0,lengthOfArray);
  51. document.getElementById(result[rand]).checked = true
  52. console.log("Found: " + result[rand]);
  53. }
  54. else {
  55.  
  56. for(index=0, len = result.length; index < len; ++index) {
  57.     document.getElementById(result[index]).checked = true
  58.     keynr = index + 1;
  59.     console.log("Found " + result.length + " fruits - Selected Nr. " + keynr + "!");
  60. }
  61.  
  62. }
  63. clickButton("Withdraw selected items");
  64.  
  65. setTimeout(location.reload(true);}, 5000);
  66.  
  67.  
  68. }
  69.        
  70.     }
  71.     }, 10);
  72. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement