0

I'm trying to get Tampermonkey to complete an online form. It works every 1 out of 4 times, all I want it to do is a simple check out process on a bigcartel store. Can anyone help?

It should work on any shop using their platform as they are all quite generic, i.e http://groundup.bigcartel.com

my code;

// ==UserScript== // @name New Userscript // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @include https://checkout.bigcartel.com/* // @include https://*.bigcartel.com/product // @include https://*.bigcartel.com/cart // @grant none // ==/UserScript== // on "/cart" page click checkout button document.getElementByName("checkout").click(); // fill first three form fields document.getElementById("buyer_first_name").value = "John"; document.getElementById("buyer_last_name").value = "Smith"; document.getElementById("buyer_email").value = "[email protected]"; // click "next" button document.getElementByType("submit").click(); 

1 Answer 1

1

There are four major issues with your TM script.

1.) Your include tags use https instead of http

2.) document.getElementByName doesn't exist.

Fix: Use document.getElementsByName("checkout")[0]

3.) Once you click the checkout button, the script immediately try to set the values of the input fields, you must wait for the page to load.

4.) document.getElementByType doesn't exist either.

Here is the working script:

// ==UserScript== // @name Script // @version 0.1 // @description try to take over the world! // @author You // @include https://checkout.bigcartel.com/* // @include http://*.bigcartel.com/product // @include http://*.bigcartel.com/cart // @grant none // ==/UserScript== // on "/cart" page click checkout button if (window.location.origin !== "https://checkout.bigcartel.com") document.getElementsByName("checkout")[0].click(); else { // fill first three form fields document.getElementById("buyer_first_name").value = "John"; document.getElementById("buyer_last_name").value = "Smith"; document.getElementById("buyer_email").value = "[email protected]"; // click "next" button document.getElementsByTagName("button")[0].click(); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.