Greasy Fork is available in English.

議論 » 作成依頼

Disable tab title changing/flickering

§
投稿日: 2022/02/07

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.

§
投稿日: 2022/02/07
編集日: 2022/02/07

// ==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);
})();

§
投稿日: 2022/02/08

That just makes it blink faster.

§
投稿日: 2022/02/08

Share an example website.

hoothinMod
§
投稿日: 2022/02/08
編集日: 2022/02/08
// ==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() {}
  });
})();
§
投稿日: 2022/02/08
編集日: 2022/02/08

@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
§
投稿日: 2022/02/08

Try document-start then

§
投稿日: 2022/02/09

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

返信を投稿

返信を投稿するにはログインしてください。