dez*_*man 5 html css windows firefox google-chrome
当有未读的电子邮件时,我正在寻找使整个屏幕闪烁红色或任何颜色的任何方法.它可以用于任何电子邮件客户端.我做了很多谷歌搜索,找不到任何东西.雷鸟的附加组件会产生一些闪烁的通知,但它只会在屏幕的右下角显得非常小.
我想到的可能是Firefox或Chrome的一些附加组件,它允许我编写可在Gmail上运行的自定义css和javascript,并使闪烁发生.任何想法都非常感谢.
我知道这不是你经常提出的问题,但你们都很棒,我不知道还有什么地方可以转.如果有一个更好的论坛可以解决这类问题,你也可以告诉我.
谢谢!
我不会制作 Chrome 插件,而是让窗口标题闪烁或使用 HTML5 通知。创建一个简单的页面,轮询您的 IMAP Gmail 是否有新邮件,并将 Gmail 包含在大型 iFrame 中。如果发现新消息,您的外部窗口可以发出通知。
HTML5 通知:http://www.html5rocks.com/en/tutorials/notifications/quick/
闪烁标题(取自于此):
var newMailBlinker = (function () {
var oldTitle = document.title,
msg = 'New Mail!',
timeoutId,
blink = function() {
document.title = document.title == msg ? ' ' : msg;
},
clear = function() {
clearInterval(timeoutId);
document.title = oldTitle;
window.onmousemove = null;
timeoutId = null;
};
return function () {
if (!timeoutId) {
timeoutId = setInterval(blink, 1000);
window.onmousemove = clear;
}
};
}());
Run Code Online (Sandbox Code Playgroud)
PHP Poll Gmail IMAP(从此采用):
$t1=time();//mark time in
$tt=$t1+(60*1);//total time = t1 + n seconds
do{
if(isset($t2)) unset($t2);//clean it at every loop cicle
$t2=time();//mark time
if(imap_num_msg($imap)!=0){//if there is any message (in the inbox)
$mc=imap_check($imap);//messages check
//var_dump($mc); die;//vardump it to see all the data it is possible to get with imap_check() and them customize it for yourself
echo 'New messages available';
}else echo 'No new messagens';
sleep(rand(7,13));//Give Google server a breack
if(!@imap_ping($imap)){//if the connection is not up
//start the imap connection the normal way like you did at first
}
}while($tt>$t2);//if the total time was not achivied yet, get back to the beginning of the loop
Run Code Online (Sandbox Code Playgroud)
jQuery AJAX 轮询您的 IMAP 脚本(从此采用):
// make the AJAX request
function ajax_request() {
$.ajax({
url: '/path/to/gmail/imap/checkMessages.php',
dataType: 'json',
error: function(xhr_data) {
// terminate the script
},
success: function(xhr_data) {
console.log(xhr_data);
if (xhr_data.status == 'No new messages') {
setTimeout(function() { ajax_request(); }, 15000); // wait 15 seconds than call ajax request again
} else {
newMailBlinker(); // blink the title here for new messages
}
}
contentType: 'application/json'
});
}
Run Code Online (Sandbox Code Playgroud)
显然您不会使用 jQuery 和 PHP 进行轮询。选择一个进行投票。我建议让客户端进行轮询,并让 PHP 在每次连接时检查 IMAP 一次。话虽这么说,这些片段应该可以帮助您开始:)
| 归档时间: |
|
| 查看次数: |
1266 次 |
| 最近记录: |