我在IE和FF中都使用了这个用户脚本,它在两者中运行良好,但在Chrome中没有任何反应。 该脚本应该计算发布到Tweetdeck的新推文,更改这些推文的背景颜色,并在标签标题中添加新的推文数量。一旦你的鼠标翻过推文,它会将数字减少1并改回颜色。代码如下:
// ==UserScript==
// @name TweetDeck Unread Notifications
// @include https://tweetdeck.twitter.com
// @include https://tweetdeck.twitter.com/*
// @grant none
// ==/UserScript==
var head, style;
head = document.getElementsByTagName('head')[0];
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = ".tdUnreadUnread { background-color: #444444; }";
head.appendChild(style);
function animate_bg(ele, from, to) {
ele.css("background-color", "rgba(68, 68, 68, " + (from += from > to ? -1 : 1) / 10 + ")");
if(from != to)
setTimeout(function() { animate_bg(ele, from, to)}, 20);
}
var counter = 0;
var loadingTime = true;
unsafeWindow.tdUnreadRefresh = function() {
var detail = $(".js-detail-content");
$("article").each(function(i) {
if (detail.length === 0) {
if (!$(this).hasClass("tdUnreadUnread")) {
$(this).addClass("tdUnreadUnread");
if (!loadingTime) {
counter++;
$(this).mouseenter(function() {
counter--;
$(this).off("mouseenter");
animate_bg($(this),10,0);
});
} else animate_bg($(this),10,0);
}
}
});
if (counter>0) {
document.title = "("+counter+") TweetDeck";
} else {
document.title = "TweetDeck";
}
};
unsafeWindow.tdUnreadLoadingOver = function() {
loadingTime = false;
};
setInterval("tdUnreadRefresh()",1000);
setTimeout("tdUnreadLoadingOver()",30000);
对此的任何帮助将不胜感激 谢谢 鲍勃