在 developer console 直接輸入
(function() {
const origDispatchEvent = EventTarget.prototype.dispatchEvent;
EventTarget.prototype.dispatchEvent = function(event) {
if (event instanceof CustomEvent) {
console.log("[Custom Event Captured]:", event.type, event.detail);
}
return origDispatchEvent.call(this, event);
};
})();
補充一下
要監聽原生事件的話
monitorEvents(document);