Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chrome.extension.sendMessage({}, function(response) {
- var readyStateCheckInterval = setInterval(function() {
- if (document.readyState === "complete") {
- clearInterval(readyStateCheckInterval);
- if(window.location.hash=="#script") {
- var oneKeyOnly = true;
- function checkItem() {
- var itemsArray = ["Apples", "Bananas", "Oranges", ];
- var matchingItems = [];
- var x = document.getElementsByClassName("item");
- for(var y = 0; y < x.length; y++){
- if(itemsArray.indexOf(x[y].getAttribute("data-name")) >= 0){
- var id = x[y].getElementsByClassName("item-checkbox")[0].getAttribute("id");
- matchingItems.push(id);
- }
- }
- return matchingItems;
- }
- function randomIntFromInterval(min,max)
- {
- return Math.floor(Math.random()*(max-min+1)+min);
- }
- function clickButton(val)
- {
- var buttons = document.getElementsByTagName('input');
- for(var i = 0; i < buttons.length; i++)
- {
- if(buttons[i].type == 'submit' && buttons[i].value == val)
- {
- buttons[i].click();
- console.log("Trying to withdraw!");
- break;
- }
- }
- }
- var result = checkItem();
- var lengthOfArray = result.length - 1;
- if (oneKeyOnly == true) {
- var rand = randomIntFromInterval(0,lengthOfArray);
- document.getElementById(result[rand]).checked = true
- console.log("Found: " + result[rand]);
- }
- else {
- for(index=0, len = result.length; index < len; ++index) {
- document.getElementById(result[index]).checked = true
- keynr = index + 1;
- console.log("Found " + result.length + " fruits - Selected Nr. " + keynr + "!");
- }
- }
- clickButton("Withdraw selected items");
- setTimeout(location.reload(true);}, 5000);
- }
- }
- }, 10);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement