I am trying to change the value of the referrer
object property document
in a Firefox extension with the following code
//Test.js
Object.defineProperty(document, "referrer", {
get: function() {
return "Test"
},
set: function(a){},
configurable: false
})
manifest.json
{
"manifest_version": 2,
"name": "Test addon",
"version": "beta",
"description": "Spoofing browser data",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["test.js"],
"run_at": "document_start"
}
]
}
I even tried with document.referrer=""
but it doesn't work, if I execute another type of code like the typical example it document.body.style.border='1px solid red'
works.
The referrer property of the document object is a property that is reported with the value of the HTTP header called "referer" (one less error).
This header is a forbidden header, that is, a value that the browser will let you change programmatically. More info: https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
Still, you can do something like this:
More info in this thread: https://stackoverflow.com/questions/9580575/how-to-manually-set-referer-header-in-javascript ,