-1

I want to code a script that redefine an existing obfuscated javascript function.

This is the function that I copied from my website.

userAgentKey: function(e) {
            return this.options.excludeUserAgent || e.push({
                key: "user_agent",
                value: this.getUserAgent()
            }), e
        },

this function return the user agent of my browser(for fingerprinting).

I want to manipulate the return value and want that this function return "exampleBrowserUserAgent". I don't have any experience in OOP.

My problem is that this doesn't redefine my code..

function userAgentKey(){
return "exampleBrowserUserAgent"
}

how can I manipulate the return value?

thanks for your help!

EDIT: the website use the fingerprintjs2.here is the link: enter link description here

  • Please could you provide a link to your website, or the script that you are trying to indirectly modify? – Matthew Spence Nov 25 '17 at 19:57
  • To manipulate your user agent, use your browser settings. (Notice that using an uncommon, non-standard value gets you fingerprinted much easier) – Bergi Nov 25 '17 at 20:00
  • i edited my question. there u can find the link for the fingerprint2.js. thank you. yes it would be easier to spoof the useragent, but i want to code a userscript because i want to manipulate all fingerprint results with random values(as example random user agents from different browsers) – MoscowDeathBrigade Nov 25 '17 at 20:11

1 Answers1

0

Wouldn't it be easier to just modify the userAgent of your browser?

Object.defineProperty(navigator, "userAgent", {value: "exampleBrowserUserAgent"});

Of course you can also directly modify the method, given that your script has access to the scope that the method is in, and the method is loaded but not yet executed:

SomeObject.userAgentKey = myUserAgentKeyFunc;

If you are trying to change the userAgent because you don't want someone else to know which browser you are using, you are better off just changing it right in the Developer Tools or create an extension that modifies it for you.

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
  • Thanks for your solution, it works fine for me! The reason why i want a userscript is because i want to code a script wich save users from different tracking technologies without install 1000 addons or edit(dangerous) browser settings (like about:config). – MoscowDeathBrigade Nov 25 '17 at 20:17