Обнаружить изменение в заголовке документа с помощью Javascript
Есть ли способ обнаружить изменениеdocument.title
/ head > title
с помощью JavaScript? Я хочу обнаружить это с помощью сценария содержания расширения Google Chrome, поэтому я не могу подключить код в JS целевой страницы, где выполняется фактическое изменение заголовка.
Я обнаружил WebKitMutationObserver, который теоретически должен быть способен обнаружить изменениеhead > title
, но это не работает для всех случаев:
// set up an observer for the title element
var target = document.querySelector('title');
var observer = new WebKitMutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation);
});
});
var config = { attributes: true, childList: true, characterData: true };
observer.observe(target, config);
// this jQuery statement fires the observer as expected ...
$('head > title').text('foo');
// ... but this doesn't:
document.querySelector('title').innerText = 'cheezburger';
// ... and neither does this:
document.title = 'lorem ipsum';
Есть идеи?