Lass dir von nem plugin oder so diese Funktion auf der Seite ausführen.
Stelle sicher, dass es das aller erste Script überhaupt ist, der event
listener muss zuerst zuschlagen, damit er funktioniert.
1 | // Guard function to make sure no symbols leak
|
2 | (function(){
|
3 | // Must be the first event listener registred
|
4 | function force_normal_click(event){
|
5 | if(!event.isTrusted) // The page faked this event, let's do nothing, it may try to detect us!!!
|
6 | return;
|
7 | if(event.button == 0) // Don't allow control over any button event action except the left one
|
8 | return;
|
9 | // Prevent other event listeners from being called, preventing them from preventing the browser default action and/or doing something else.
|
10 | event.stopPropagation();
|
11 | event.stopImmediatePropagation();
|
12 | }
|
13 | // Actually register the function
|
14 | addEventListener("mousedown" , force_normal_click, true);
|
15 | addEventListener("mouseup" , force_normal_click, true);
|
16 | addEventListener("click", force_normal_click, true);
|
17 | function force_normal_context_menu(event){
|
18 | if(!event.isTrusted) // The page faked this event, let's do nothing, it may try to detect us!!!
|
19 | return;
|
20 | // Prevent other event listeners from being called, preventing them from preventing the browser default action and/or doing something else.
|
21 | event.stopPropagation();
|
22 | event.stopImmediatePropagation();
|
23 | }
|
24 | addEventListener('contextmenu', force_normal_context_menu, true);
|
25 | })();
|