Git Product home page Git Product logo

Comments (3)

joshlewis avatar joshlewis commented on June 30, 2024

Seconded! This plugin needs some logic that will watch the page title and overwrite it again and again with the chosen title. It looks like Mutation Observers are the performant way to do that these days.

Something like this seems to work pretty well at writing to the console whenever the document title changes:

new MutationObserver(function() {
    //The code to change the title back to what Tab Modifier wants would go here
    //But for now we'll just log it for demo purposes so you can see it works.
    console.log("Title changed to "+document.title);
}).observe(document.querySelector('title'),{
    childList: true
});

See here for more: https://stackoverflow.com/questions/2497200/how-to-listen-for-changes-to-the-title-element

from chrome-tab-modifier.

joshlewis avatar joshlewis commented on June 30, 2024

As a stopgap, I made a JavaScript bookmarklet that will keep the tab's name set until the page is reloaded or navigated to a new page. Might be helpful to some people. If you save this as the "URL" in a bookmark, clicking the bookmark will as you to input the tab name you want, and there you go.

In one line, for a bookmarklet:

javascript: (() => { window.specialTitle = prompt('Tab name'); new MutationObserver(function() { if (document.title !== window.specialTitle) {document.title = window.specialTitle;} }).observe(document.querySelector('title'),{ childList: true }); document.title = window.specialTitle; })();

Or easier to read:

javascript: (() => { 
    window.specialTitle = prompt('Tab name');
    
    new MutationObserver(function() {
        if (document.title !== window.specialTitle) {
            document.title = window.specialTitle;
        } }).observe(document.querySelector('title'),{ childList: true }); 
    
    document.title = window.specialTitle; 
})();

from chrome-tab-modifier.

sylouuu avatar sylouuu commented on June 30, 2024

Hi @kaledaddy,

Seems to work now on Notion since the 1.0 is out!

Bests

from chrome-tab-modifier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.