Answer the question
In order to leave comments, you need to log in
How to change page title before DOM is loaded (Chrome extension)?
I'm trying to change the title of the page through the chrome extension before it is loaded, but the DOM has not yet been loaded and this does not work. Are there any options? You need to change the title before the page loads so that the old one is not noticeable.
Answer the question
In order to leave comments, you need to log in
I found a non-crutch solution (someone like it, maybe it's better):
var title = document.createElement('title')
title.innerText = 'всем привет я из internet'
document.documentElement.appendChild(title)
This of course can be done, but only through a crutch. Specify the run_at option with a value of document_start in your extension's manifest to have your content script run before the document is ready:
{
"name" : "Имя расширения",
"manifest_version" : 2,
// ............................
"content_scripts" : [
{
"matches" : [ "https://*.site.ru/*", ],
"run_at": "document_start",
"js" : [ "content-script.js" ]
}
]
}
document.write('');
document.close();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question