Chrome 用户脚本检查新推文
所以我在 Chrome 中始终打开 twitter.com 的一个选项卡,并且我编写了一个用户脚本来经常检查文档标题是否有新推文。
由于 Twitter 网页界面会自动检查,如果有两条新推文,它将显示 (2) Twitter / Home
作为标题。一切都按照我想要的方式工作,现在我已经向我显示了一条 alert()
消息。我想提供一个更微妙的通知。
这样做的目的是能够将 Twitter 选项卡“固定”到网站图标并仍然收到通知。我尝试过寻找动态更改页面图标的方法,但 Chrome 似乎不支持这一点。大家对此还有其他想法吗?这样它就可以通知我新的推文,而不会用 alert()
框窃取焦点?
如果有人感兴趣的话,这是代码:
checkTweets();
function checkTweets()
{
var newTweets = document.title.match(/[\d\.]+/g);
if(newTweets != null)
{
alert(newTweets[0]);
}
setTimeout("checkTweets()", 10000);
}
so I have a tab for twitter.com open all the time in Chrome and I've written a userscript that checks the document title every so often for new tweets.
Since the Twitter web interface automatically checks, it will show (2) Twitter / Home
as the title if there are two new tweets. Everything works as I want it to and right now I have it show me an alert()
message. I would like to provide a more subtle notification.
The purpose of this is to be able to "pin" the Twitter tab to just the favicon and still get notifications. I've tried searching for ways to dynamically change the favicon of a page but it doesn't look like Chrome supports that. Do guys have any other ideas for this so it can notify me of new tweets without stealing focus with an alert()
box?
Here is the code if anyone is interested:
checkTweets();
function checkTweets()
{
var newTweets = document.title.match(/[\d\.]+/g);
if(newTweets != null)
{
alert(newTweets[0]);
}
setTimeout("checkTweets()", 10000);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Chritter 会将 Twitter 通知放入您的状态栏中。如果您想要不同的 UI,您可能需要考虑制作自己的扩展。有关扩展程序可以更改用户界面哪些部分的信息,请参阅文档。
Chritter will put twitter notifications in your statusbar. If you want a different UI, you might want to think about making your own extension. See the documentation for info about what parts of the UI an extension can change.