2017-12-04 27 views
0

Tampermonkey가 온라인 양식을 작성하려고합니다. 그것은 4 번 중 1 번마다 작동하며, bigcartel 스토어에서 간단한 체크 아웃 프로세스 만 수행하면됩니다. 누구든지 도와 줄 수 있습니까?Tampermonkey 스크립트는 산발적으로 작동합니까?

그것은 그들은 모두 매우 일반적이기 때문에 자신의 플랫폼을 사용하는 모든 상점에서 작동해야, 즉 http://groundup.bigcartel.com

내 코드;

// ==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

TM 스크립트에는 네 가지 주요 문제가 있습니다.

1.) 귀하의 태그가 존재하지 않는 https 대신 document.getElementByName)

2. http의를 사용할 수 있습니다.

수정 : 페이지가로드 될 때까지 사용 document.getElementsByName("checkout")[0]

3) 당신이 checkout 버튼을 클릭하면, 스크립트가 즉시 입력 필드의 값을 설정하려고 기다려야합니다.

4) document.getElementByType도 존재하지 않습니다.

// ==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(); 
} 
+1

이 완벽하게 작동합니다 : 여기

는 작업 스크립트입니다 – oversoon