私は2つの異なるスクリプトを持っています。1 つの終わりに、別のスクリプトを開始する新しい Web ページを開き、そのスクリプトが値を true に設定するのを待って、最初のスクリプトが別のページを開くことを許可します。
これは、最初のスクリプトの最後に呼び出される関数のスクリプトです。フラグ値 continueValue が true に設定されるのを待ちます。コンソールには、他のスクリプトが値を true に変更していないことを意味する「checking flag」メッセージが何度も表示されます。
function checkFlag() {
console.log("Checking flag");
if(GM_getValue("continueValue") === false) {
window.setTimeout(checkFlag, 2000); /* this checks the flag every 3000 milliseconds*/
} else {
//--- Opens the next cove
if (!(currentCoveNum = -1)) {
window.open(coveLinks[currentCoveNum + 1],"_self");
}
}
}
次のスクリプトの最後で、次のコードが実行されます。
//--- If the text "Next Creature" exists on the page, click next creature button
if ((document.documentElement.textContent || document.documentElement.innerText).indexOf('Next Creature') > -1) {
window.location.href = nextCreatureLink[0].href;
//--- Otherwise set the continue value to true to allow Super Auto Feed, Open Coves to open the next cove
} else {
GM_setValue("continueValue", true);
console.log("continueValue is "+GM_getValue("continueValue"));
setTimeout(function() {
window.close();
}, (2 * 1000));
}
問題は、このスクリプトが「continueValue is」というメッセージに到達すると、true が表示され、他のスクリプトが次のページを開く必要があることを意味しますが、そうではありません。フラグが真になるかどうかをチェックし続けるだけです。
getValue と setValue がスクリプト間で機能しないのではないでしょうか? または、フラグが true になることを確認するループの何かが間違っている可能性があります。
誰かが私のスクリプトのどこが間違っているかを教えてくれたら、とても助かります。