Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mutation observer on broken pages #33

Open
wants to merge 1 commit into
base: web-extension
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions managetitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,14 @@ var addUrlToWindowTitle = (function() {

});

var config = { attributes: true, childList: true, characterData: true };
var target = document.querySelector('head > title');

// Only run the observer on tabs that have a <head /> (e.g., not about:blank)
var config = { attributes: true, childList: true, characterData: true, subtree: true };
// in theory, the selector should be head > title, but some in some webpages with broken
// HTML the title tag is automatically moved to the body by the browser, and changes to it
// still change the actual website title. the title element also cannot validly appear
// anywhere else, so just selecting title is fine
var target = document.querySelector('title');

// Only run the observer on tabs that have a <title /> (e.g., not about:blank)
if(target !== null){
titleObserver.observe(target, config);
}
Expand Down