My website is currently using a third-party script called Chaordic loader.js for product recommendations, but I am facing an issue where it overrides the document.referrer
with inaccurate information, causing me quite a headache.
Query: Is there a way to prevent this interference? Can I somehow lock or protect the document.referrer
from being modified?
While one option could be to terminate the contract with the company providing the script, I want to explore other solutions first. I have the ability to include JavaScript code before or after the third-party code, but I am unable to directly modify it.
The following snippet represents the third-party code that alters document.referrer
:
var t = window.chaordic && window.chaordic.readCookie && window.chaordic.readCookie(e);
Object.defineProperty(window.document, "referrer", {
configurable: false,
get: function() { return t }
});