Javascriptへのdocument.title
/経由での変更を検出する方法はありますか?head > title
これをGoogleChrome拡張コンテンツスクリプトで検出したいので、実際のタイトル変更が行われるターゲットページの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';
何か案は?