我正在嘗試使用內容腳本瀏覽網頁。但是該函數會一直運行,因爲每次頁面發生變化時都會通過腳本運行。我想知道是否有更好的方法來做到這一點,因爲它是一個資源豬,也不允許用戶與頁面交互,因爲不斷刷新。打開窗口並瀏覽頁面
下面是有問題的代碼,很抱歉,如果它看起來很奇怪。我沒有更多的幾個星期瞭解jQuery的知識。
$(document).ready(function(){
console.log("Made it here" + window.location.href);
loc = window.location.href;
match = loc.match('http://url.com/uc/');
if (match) {
window.location = "http://url.com/uc/health/index/1";
console.log("2 here");
window.location = "http://url.com/uc/health/communication/createSelectTemplate";
console.log("3 here");
chrome.storage.local.get('formOption', function(result) {
document.getElementById('formTemplate').value = result.formOption;
document.forms[0].submit();
});
}
});
的原因,我不得不用,因爲誰使這個網站有超時餅乾值之前,導航三個窗口和網頁無法前一個加載之前被調用。 這是一個內容腳本,所以所有的代碼都在下一頁。也許如果有一種方法來檢查確切的網址?但是當我一直在玩這個計算機時沒有區分。
urlhere.com/uc/
和
urlhere.com/uc/health/index/1
你爲什麼$(文件)。就緒裏面的$(document).read? –
'window.location'會加載新的網頁,新的內容和所有下一個代碼不會工作 –
我試圖等待每個頁面準備好。但看着它它什麼都不做,所以我將它們刪除。 –