您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds unread notifications count in the tab title
当前为
- // ==UserScript==
- // @name Twitter - adds unread notifications count in the tab title
- // @namespace rikkie
- // @description Adds unread notifications count in the tab title
- // @include https://twitter.com/
- // @version 1
- // @grant none
- //
- // Thanks a lot to wOxxOm for his valuable help
- // ==/UserScript==
- var lastvalue = document.querySelector('.count > span:nth-child(1)').innerHTML;
- if (lastvalue != '0'){
- document.title = lastvalue + '|' + document.title;
- };
- var target = document.querySelector('head > title');
- var observer = new MutationObserver(function (mutations) {
- mutations.forEach(function (mutation) {
- if (document.title.indexOf('|') == -1 && document.querySelector('.count > span:nth-child(1)').innerHTML != '0' ) {
- document.title = document.querySelector('.count > span:nth-child(1)').innerHTML + '|' + document.title;
- lastvalue = document.querySelector('.count > span:nth-child(1)').innerHTML;
- }
- });
- })
- var config = {attributes: true, childList: true, characterData: true}
- observer.observe(target, config);