Results 1 to 3 of 3

Thread: Help me edit this GM script?

  1. #1
    Infiniti's Avatar
    Joined
    May 2014
    Posts
    440
    Userbars
    10
    Thanks
    243
    Thanked
    413/167
    DL/UL
    56/0
    Mentioned
    37 times
    Time Online
    37d 16h 37m
    Avg. Time Online
    15m

    Help me edit this GM script?

    I'll apologize in advance, I don't know any programming languages well. xD That being said;

    I came across this Neocola machine script. After it gets your prize, you have the manually click "Play again", then "Onward". I wanted to add a redirect link from /neocola3 back to /neocola 2 to allow the script to loop until all the tokens are used.

    (you need an account to see links)

    I tried adding


    To the script, but it seemed to have no effect. Anyone know what I'm doing wrong, or perhaps a different remedy to this problem? I know we could edit it so it clicks both buttons, but I think it would be easier to just link back to the previous page. I feel like this is pretty simple, but my lack of knowledge is showing. +rep for help, and we can add the script to the GM script repository when finished to help everyone else. Thanks in advance, I'll keep working on it for the time being. xD

    EDIT: Oh hey I got it working. I'll post the script in a few minutes after I change the timing.
    Last edited by Infiniti; 10-12-2017 at 03:20 PM.

  2. #2
    Accelerator's Avatar
    Joined
    Jul 2013
    Posts
    4,995
    Userbars
    26
    Thanks
    1,986
    Thanked
    3,789/1,696
    DL/UL
    178/0
    Mentioned
    744 times
    Time Online
    335d 1h 18m
    Avg. Time Online
    2h 3m
    Code:
    // ==UserScript== 
    //   @(you need an account to see links) Neocola Machine APer
    //   @(you need an account to see links)space Neocola Machine APer
    // @grant   none
    //   @(you need an account to see links)cription Selects a random combination at the Neocola Machine
    // @include (you need an account to see links)
    // @include (you need an account to see links)
    // @include (you need an account to see links)
    // @grant   none
    // ==/UserScript==
    
    var butt = document.getElementsByTagName('input');
    
    //Selects Random Token
    var elements = document.getElementsByName('token_id');
    for(var i = 0; i < elements.length; ++i){
        var max = elements[i].length;
        max = parseInt(max)
        max = max-1;
        var tempN = Math.floor((Math.random()*max)+1);
    	elements[i].selectedIndex = tempN;
    }
    
    // Predefined Combo
    // Selects Combination
    var selCriteria = document.querySelector("select[name=neocola_flavor]");
    if (selCriteria != null) selCriteria.selectedIndex = 6;
    var selCriteria = document.querySelector("select[name=red_button]");
    if (selCriteria != null) selCriteria.selectedIndex = 4;
    
    
    /* // Random Combo
    // var selCriteria = document.querySelector("select[name=neocola_flavor]");
    // if (selCriteria != null) selCriteria.selectedIndex = 3;
    var elements = document.getElementsByName('neocola_flavor');
    for(var i = 0; i < elements.length; ++i){
        var max = elements[i].length;
        max = parseInt(max)
        max = max-1;
        var tempN = Math.floor((Math.random()*max)+1);
    	elements[i].selectedIndex = tempN;
    }
    // var selCriteria = document.querySelector("select[name=red_button");
    // if (selCriteria != null) selCriteria.selectedIndex = 2;
    var elements = document.getElementsByName('red_button');
    for(var i = 0; i < elements.length; ++i){
        var max = elements[i].length;
        max = parseInt(max)
        max = max-1;
        var tempN = Math.floor((Math.random()*max)+1);
    	elements[i].selectedIndex = tempN;
    } */
    //Presses buttons
    for(var j = 0; j < butt.length; ++j) {
     	if (butt[j].value == "Onward!")
        {
            setTimeout(777);
            butt[j].click();   
        }
    }
    for(var j = 0; j < butt.length; ++j) {
     	if (butt[j].value == "Continue to your doom...")
        {
            setTimeout(777);
            butt[j].click();   
        }
    }
    for(var j = 0; j < butt.length; ++j) {
     	if (butt[j].value == "Play Again!")
        {
            setTimeout(777);
            butt[j].click();   
        }
    }
    
    
    console.log(butt);
    @(you need an account to see links)
    i made that for myself like 3 years ago, it just clicks buttons and randomly selects stuff from the drop-down lists
    Right now it's set to use a pre-defined combination, if you want a random one comment the entire section from line 24 to 29 and uncomment from 32 to 52.
    Last edited by Accelerator; 10-12-2017 at 03:21 PM.

    (you need an account to see links)
    (you need an account to see links)
    (you need an account to see links)
    (you need an account to see links)

    "Date et dabitur vobis"
    「Let's fight 恐れはない」


    "A quantum supercomputer calculating for a thousand years could not even approach the number of f��ks I do not give"

    「君が望むモノは何?」

  3. The Following User Says Thank You to Accelerator For This Useful Post:

    Infiniti (10-12-2017)

  4. #3
    Infiniti's Avatar
    Joined
    May 2014
    Posts
    440
    Userbars
    10
    Thanks
    243
    Thanked
    413/167
    DL/UL
    56/0
    Mentioned
    37 times
    Time Online
    37d 16h 37m
    Avg. Time Online
    15m
    Quote Originally Posted by Accelerator View Post
    Code:
    // ==UserScript== 
    //   @(you need an account to see links) Neocola Machine APer
    //   @(you need an account to see links)space Neocola Machine APer
    // @grant   none
    //   @(you need an account to see links)cription Selects a random combination at the Neocola Machine
    // @include (you need an account to see links)
    // @include (you need an account to see links)
    // @include (you need an account to see links)
    // @grant   none
    // ==/UserScript==
    
    var butt = document.getElementsByTagName('input');
    
    //Selects Random Token
    var elements = document.getElementsByName('token_id');
    for(var i = 0; i < elements.length; ++i){
        var max = elements[i].length;
        max = parseInt(max)
        max = max-1;
        var tempN = Math.floor((Math.random()*max)+1);
    	elements[i].selectedIndex = tempN;
    }
    
    // Predefined Combo
    // Selects Combination
    var selCriteria = document.querySelector("select[name=neocola_flavor]");
    if (selCriteria != null) selCriteria.selectedIndex = 6;
    var selCriteria = document.querySelector("select[name=red_button]");
    if (selCriteria != null) selCriteria.selectedIndex = 4;
    
    
    /* // Random Combo
    // var selCriteria = document.querySelector("select[name=neocola_flavor]");
    // if (selCriteria != null) selCriteria.selectedIndex = 3;
    var elements = document.getElementsByName('neocola_flavor');
    for(var i = 0; i < elements.length; ++i){
        var max = elements[i].length;
        max = parseInt(max)
        max = max-1;
        var tempN = Math.floor((Math.random()*max)+1);
    	elements[i].selectedIndex = tempN;
    }
    // var selCriteria = document.querySelector("select[name=red_button");
    // if (selCriteria != null) selCriteria.selectedIndex = 2;
    var elements = document.getElementsByName('red_button');
    for(var i = 0; i < elements.length; ++i){
        var max = elements[i].length;
        max = parseInt(max)
        max = max-1;
        var tempN = Math.floor((Math.random()*max)+1);
    	elements[i].selectedIndex = tempN;
    } */
    //Presses buttons
    for(var j = 0; j < butt.length; ++j) {
     	if (butt[j].value == "Onward!")
        {
            setTimeout(777);
            butt[j].click();   
        }
    }
    for(var j = 0; j < butt.length; ++j) {
     	if (butt[j].value == "Continue to your doom...")
        {
            setTimeout(777);
            butt[j].click();   
        }
    }
    for(var j = 0; j < butt.length; ++j) {
     	if (butt[j].value == "Play Again!")
        {
            setTimeout(777);
            butt[j].click();   
        }
    }
    
    
    console.log(butt);
    @(you need an account to see links)
    i made that for myself like 3 years ago, it just clicks buttons and randomly selects stuff from the drop-down lists
    Right now it's set to use a pre-defined combination, if you want a random one comment the entire section from line 24 to 29 and uncomment from 32 to 52.
    Very nice, thank you. I knew someone had already made one, but I searched around and couldn't find one so I figured I would edit the one already out there. I was trying to get the setTimeout to work for the redirect on mine, but was struggling with it. I scrapped my project as yours is perfect for me. Thanks again bro.

  5. The Following User Says Thank You to Infiniti For This Useful Post:

    Accelerator (10-12-2017)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •