AutoPagerizeと同時作業させたくてeventを調査した。
ソースコードから dispatchEvent をキーワードに検索すると
GM_AutoPagerizeLoaded
AutoPagerize_DOMNodeInserted
GM_AutoPagerizeNextPageLoaded
が見つかった。
// ==UserScript==
// @name TestEventFromAutopagerized
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.addEventListener("GM_AutoPagerizeLoaded",report,true);
window.addEventListener("AutoPagerize_DOMNodeInserted",report,true);
window.addEventListener("GM_AutoPagerizeNextPageLoaded",report,true);
function report(e){
console.log(e);
}
// Your code here...
})();
簡単にプログラムを作ってみてテストしたら発火してたのは
AutoPagerize_DOMNodeInserted
GM_AutoPagerizeNextPageLoaded
で
GM_AutoPagerizeLoaded
は発火していなかった。何故だろう。on Firefox 75
GM_AutoPagerizeNextPageLoaded
GM_AutoPagerizeNextPageLoaded { target: HTMLDocument https://www.xxxx.com/jp/category/, isTrusted: false, srcElement: HTMLDocument https://www.xxxx.com/jp/category/, currentTarget: Window, eventPhase: 1, bubbles: true, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, … }
target.activeElement: <body> で最初も読み込んだページも全体を指している。
AutoPagerize_DOMNodeInserted
AutoPagerize_DOMNodeInserted { target: div#xxx, isTrusted: false, relatedNode: body, prevValue: "null", newValue: "https://www.xxxx.com/jp/category/?page=2", attrName: "null", attrChange: 0, MODIFICATION: 1, ADDITION: 2, REMOVAL: 3, … }
target: <div id="xxx"> と読み込んだ部分だけを指している違いがある

