爲了讓我的腳本更加耐用
無法檢測
健壯,我決定使用更多的人類事件,即mouseover,mousedown,mouseup,mouseout。由於這些是jQuery的依賴,我已經加入jQuery + Greasmonkey:mouseover()不是函數
// @require https://code.jquery.com/jquery-3.1.1.slim.min.js
給我的腳本的頂部,並且,按照在Greasmonkey Wiki附帶的說明這一行:
this.$ = this.jQuery = jQuery.noConflict(true);
當我運行該腳本,我在控制檯中得到這個錯誤:
Uncaught TypeError: document.getElementsByClassName(...)[0].mouseover is not a function
這將導致我相信,jQuery尚未加載腳本安裝。我已經嘗試了相同的代碼,沒有'noConflict',它有效地打破了網站,並且仍然返回上述錯誤。
這裏是我的代碼:
else if (document.getElementsByClassName('thumb-container active')[0] == null &&
document.getElementsByClassName('feed-ajax-next')[0] != null){
document.getElementsByClassName('feed-ajax-next')[0].mouseover();
console.log("M_over");
document.getElementsByClassName('feed-ajax-next')[0].mousedown();
console.log("M_down");
document.getElementsByClassName('feed-ajax-next')[0].mouseup();
console.log("M_up");
document.getElementsByClassName('feed-ajax-next')[0].mouseout();
console.log("M_out");
尼斯快速回答!謝謝! –