exile-center / better-trading

QoL improvements for the official PathOfExile trading site.
30 stars 6 forks source link

Update the page title to match the active bookmark item #71

Closed pboutin closed 1 year ago

pboutin commented 3 years ago

Idea from Discord

would it be possible to rename the page title to whatever bookmark you're currently on?
say i have a search named "Dying Sun", it would be nice to see the tab named dying sun instead of all trades having the default title
maybe a "Live" icon too :smile:
pboutin commented 3 years ago

Seems like the trade site's JS is always updating the document.title, so the extension cannot reliably change it 😞

bellstrand commented 3 years ago

@pboutin This should be possible, or are you limited in what you can do because it's an extension? They only update when you navigate, search, etc... so the code below should solve your problem.

let ourDocumentTitle = "Dying Sun"
new MutationObserver(function() {
    if(document.title !== ourDocumentTitle) {
        document.title = ourDocumentTitle
    }
}).observe(document.querySelector("title"), { childList: true })

This should work great in all evergreen browsers. https://caniuse.com/?search=MutationObserver

As for a "live" icon, we'd have to observe the content of Activate Live Search button, since i can't find any other visible change atm.

pboutin commented 3 years ago

@bellstrand that might work, will have to give it a try, thanks for the idea!