Skip to content

Instantly share code, notes, and snippets.

@CQD

CQD/wakeup.js

Created Mar 20, 2010
Embed
What would you like to do?
為 Firefox 增加振奮精神功能的 Jetpack
var currDoc = jetpack.tabs.focused.contentDocument;
var th; // Timer hanlder, used for clear timeout timer
/*啟動時,顯示訊息,兩秒後隱藏訊息*/
getUp = function(){
hideGetUpBox();
currDoc = jetpack.tabs.focused.contentDocument;
showGetUpBox();
th = setTimeout(hideGetUpBox,2000);
}
/*顯示讓人振奮精神的台詞*/
function showGetUpBox(){
clearTimeout(th);
$('body',currDoc).append( "<div id='getupbox' style='position:fixed; z-index:100000; top:0; left:0; width:100%; text-align:center; height:100%; background-color:black; color:white; font-size:50px;'><br><br>醒來!!現在也才~三點~</div>" );
}
/*隱藏讓人振奮精神的台詞*/
function hideGetUpBox(){
$('#getupbox',currDoc).remove();
}
/*在右鍵選單增加讓人振奮精神的選項*/
jetpack.future.import("menu");
jetpack.menu.context.page.add({label: "振奮精神", command: getUp});
/*在工具列增加讓人振奮精神的按鈕*/
jetpack.future.import("toolbar");
var myButton = {id: "getUp",label: "振奮精神",tooltip: "讓人振奮精神的按鈕",image: "http://www.mozilla.org/favicon.ico",onclick: function(event) { getUp(); }}
jetpack.toolbar.navigation.append(myButton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment