Reputation: 729
I'm trying to modify/limit/prevent access to certain JS commands of my browser. For example commands like navigator.clipboard
; However, I'm not sure how to approach this.
Is it possible to override these commands with user-defined javascript injected in the page, or do i have to edit the browser's javascript compiler and re-compile it from source for this?
I'm not really familiar with browsers and want to save time by knowing a general direction to follow. Thanks
Upvotes: 0
Views: 89
Reputation: 6757
First of all navigator.clipboard
is not a function, but here is an example using the read
function of navigator.clipboard
:
navigator.clipboard.read = function (originalFunction) {
return function (yourParamsYouWantForThisFunction) {
// Do Stuff you wanna do before the real call. For example:
console.log(yourParamsYouWantForThisFunction);
// Call the original function
return originalFunction.call();
};
}(navigator.clipboard.read); // Pass the original function reference as a parameter
You may wonder, why there are two function
statements:
navigator.clipboard.read
function.navigator.clipboard.read()
. Upvotes: 1