You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I have noticed that some websites uses click() to open popups.
For example:
(()=>{consturl='/popup';constcreateElm=document.createElement("a");createElm.href=url;createElm.target="_blank";createElm.click();/* do something, for example load video player */console.log('something');})();
We could add a scriptlet to prevent click if clicked element has specific attribute (like href) with specific content.
For example (might need improvements, just an idea):
(()=>{constpreventClick=(element,content)=>{constwrapper=(target,thisArg,args)=>{constmatch=content.split(':');const[attribute,text]=match;if(thisArg.matches(element)&&thisArg[attribute].includes(text)){return;}returnReflect.apply(target,thisArg,args);};consthandler={apply: wrapper};window.HTMLElement.prototype.click=newProxy(window.HTMLElement.prototype.click,handler);};// Prevent clicking "a" element if "href" contains "popup"preventClick('a','href:popup');})();
The text was updated successfully, but these errors were encountered:
Recently I have noticed that some websites uses
click()
to open popups.For example:
We could add a scriptlet to prevent
click
if clicked element has specific attribute (likehref
) with specific content.For example (might need improvements, just an idea):
The text was updated successfully, but these errors were encountered: