簡體   English   中英

阻止或偵聽用戶在開發人員工具中刪除事件偵聽器?

[英]Prevent or Listen for a user removing event listeners in developer tools?

如何防止或偵聽用戶在開發人員工具中刪除事件偵聽器?

這可能嗎?

通過開發者工具移除樣本

在上面的示例中,當用戶刪除“事件偵聽器”時,我想對操作采取行動。 是否有事件偵聽器的事件偵聽器?

 const removeEventListenerOriginal = EventTarget.prototype.removeEventListener; const p = document.querySelector("p"); const onClick = e => console.log("clicked", e.target.tagName); EventTarget.prototype.removeEventListener = function(...args) { const [eventType, handler, capture] = args; console.log(`Event Listener Removed For`, this, { eventType, handler, capture }); // your logic here // call the original function or not. its up to you removeEventListenerOriginal.call(this, ...args); // or removeEventListenerOriginal.apply(this, args); } p.addEventListener("click", onClick); // try removing the event from dev console
 <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo</p>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM