Greasy Fork is available in English.

Discussions » Creation Requests

Disable tab title changing/flickering

§
Posted: 07.02.2022

Many websites have a title that changes.
Think social media that adds a (1) to the title when you get a message, or any website with ads that make the title blink to catch your attention.
That's insufferable.
I've tried using foxreplace to cancel any changes to the title (deleting any <<([_a-z][a-z0-9_\s]*\.\s*)*document\s*.\s*title\s*=>> within page source) but it works too 'late' wrt to the page loading.

Would that be doable through a user script?
Foxreplace's dev recommended I use one through greasemonkey using the run-at property to execute it at the earliest, but I don't know how to code in js.

§
Posted: 07.02.2022
Edited: 07.02.2022

// ==UserScript==
// @name Tab Title Keeper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Prevents the tab title from changing.
// @author hacker09
// @match *
// @grant none
// @run-at document-body
// ==/UserScript==

(function() {
'use strict';
const title = document.title;
setInterval(function () { document.title = title; }, 1000);
})();

§
Posted: 08.02.2022

That just makes it blink faster.

§
Posted: 08.02.2022

Share an example website.

hoothinMod
§
Posted: 08.02.2022
Edited: 08.02.2022
// ==UserScript==
// @name Tab Title Keeper
// @namespace hoothin
// @version 0.1
// @description Prevents the tab title from changing.
// @author hoothin
// @match *
// @grant none
// @run-at document-body
// ==/UserScript==

(function() {
  'use strict';
  const title = document.title;
  Object.defineProperty(document, 'title', {
      get: function() {return title},
      set: function() {}
  });
})();
§
Posted: 08.02.2022
Edited: 08.02.2022

@hacker09 Any social media/blogging site, literally every streaming service, most news website, and lots of others.


@hoothin I use greasemonkey and the <<@match *>> line was causing problems, so I used <<@include *>> instead.
That at least doesn't make the title change more, but it still changes.
Maybe this is executed too late ?(like some interval is already going on)
Or too early ?(like if the set property is redefined later)

Is there no way to just force every script to go through a regex replace before they get executed?

hoothinMod
§
Posted: 08.02.2022

Try document-start then

§
Posted: 09.02.2022

Yeah, I tried all the run-at options. Does it work for you?

Post reply

Sign in to post a reply.