forked from feiruo/userChromeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
feiruo
committed
Aug 4, 2014
1 parent
18de305
commit 12d6e67
Showing
6 changed files
with
268 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,102 @@ | ||
// ==UserScript== | ||
// @name AwesomeBookmarkbar | ||
// @description 智能书签工具栏 | ||
// @homepage https://github.com/feiruo/userchromejs/ | ||
// @author feiruo | ||
// @charset utf-8 | ||
// @version 0.2 | ||
// @compatibility Firefox 24.0 | ||
// @note 0.2 增加鼠标移到地址栏自动显示书签工具栏,移出隐藏 | ||
// @note 点击地址栏显示书签工具栏。 | ||
// @note 地址栏任意按键,地址栏失去焦点后自动隐藏书签工具栏。 | ||
// @note 左键点击书签后自动隐藏书签工具栏。 | ||
// @name AwesomeBookmarkbar.uc.js | ||
// @description 智能书签工具栏 | ||
// @author feiruo | ||
// @compatibility Firefox 24.0 | ||
// @charset UTF-8 | ||
// @include chrome://browser/content/browser.xul | ||
// @id [73FCA65B] | ||
// @startup window.AwesomeBookmarkbar.init(); | ||
// @shutdown window.AwesomeBookmarkbar.onDestroy(); | ||
// @reviewURL http://bbs.kafan.cn/thread-1726260-1-1.html | ||
// @homepageURL https://github.com/feiruo/userChromeJS | ||
// @note 点击地址栏显示书签工具栏。 | ||
// @note 地址栏任意按键,地址栏失去焦点后自动隐藏书签工具栏。 | ||
// @note 左键点击书签后自动隐藏书签工具栏。 | ||
// @version 0.2.1 去除鼠标移到地址栏自动显示书签工具栏 | ||
// @version 0.2 增加鼠标移到地址栏自动显示书签工具栏,移出隐藏 | ||
// ==/UserScript== | ||
(function() { | ||
var PTBar = document.getElementById("PersonalToolbar"); | ||
if (window.AwesomeBookmarkbar) { | ||
window.AwesomeBookmarkbar.onDestroy(); | ||
delete window.AwesomeBookmarkbar; | ||
} | ||
|
||
var PersonalToolbar = document.getElementById("PersonalToolbar"); | ||
|
||
var placesCommands = document.getElementById("placesCommands"); | ||
|
||
setToolbarVisibility(PTBar, PTBar.collapsed); | ||
var AwesomeBookmarkbar = {}; | ||
|
||
function hideToolbar(e) { | ||
if (e.button == 2 || (e.button == 0 && !(e.metaKey || e.shiftKey || e.ctrlKey))) return; | ||
PTBar.collapsed = true; | ||
} | ||
AwesomeBookmarkbar.init = function() { | ||
setTimeout(function() { | ||
setToolbarVisibility(PersonalToolbar, PersonalToolbar.collapsed); | ||
}, 500); | ||
setToolbarVisibility(PersonalToolbar, PersonalToolbar.collapsed); | ||
this.addListener(this.hideToolbar, this.cHideToolbar, this.mShowToolbar, this.mHideToolbar, this.keyHide); | ||
}; | ||
|
||
PTBar.addEventListener("command", hideToolbar, false); | ||
PTBar.addEventListener("click", hideToolbar, false); | ||
placesCommands.addEventListener("command", hideToolbar, false); | ||
AwesomeBookmarkbar.onDestroy = function() { | ||
this.removeListener(this.hideToolbar, this.cHideToolbar, this.mShowToolbar, this.mHideToolbar, this.keyHide); | ||
}; | ||
|
||
gURLBar.addEventListener('click', function(e) { | ||
if (e.button == 0) { | ||
PTBar.collapsed = false; | ||
} | ||
}, false); | ||
AwesomeBookmarkbar.addListener = function(obj, cHideToolbar, mShowToolbar, mHideToolbar, keyHide) { | ||
PersonalToolbar.addEventListener("command", obj, false); | ||
PersonalToolbar.addEventListener("click", obj, false); | ||
placesCommands.addEventListener("command", obj, false); | ||
|
||
gURLBar.addEventListener('click', cHideToolbar, false); | ||
|
||
PersonalToolbar.addEventListener('mouseover', mShowToolbar, false); | ||
|
||
PersonalToolbar.addEventListener('mouseout', mHideToolbar, false); | ||
|
||
gURLBar.addEventListener('mouseout', mHideToolbar, false); | ||
|
||
PTBar.addEventListener('mouseover', function(e) { | ||
PTBar.setAttribute('collapsed', 'false'); | ||
}, false); | ||
gURLBar.addEventListener('keydown', keyHide, false); | ||
}; | ||
|
||
PTBar.addEventListener('mouseout', function(e) { | ||
PTBar.setAttribute('collapsed', 'true'); | ||
}, false); | ||
AwesomeBookmarkbar.removeListener = function(obj, cHideToolbar, mShowToolbar, mHideToolbar, keyHide) { | ||
PersonalToolbar.removeEventListener("command", obj, false); | ||
PersonalToolbar.removeEventListener("click", obj, false); | ||
placesCommands.removeEventListener("command", obj, false); | ||
|
||
gURLBar.addEventListener('mouseover', function(e) { | ||
PTBar.setAttribute('collapsed', 'false'); | ||
}, false); | ||
gURLBar.removeEventListener('click', cHideToolbar, false); | ||
|
||
gURLBar.addEventListener('mouseout', function(e) { | ||
PTBar.setAttribute('collapsed', 'true'); | ||
}, false); | ||
PersonalToolbar.removeEventListener('mouseover', mShowToolbar, false); | ||
|
||
gURLBar.addEventListener('keydown', function(e) { | ||
PersonalToolbar.removeEventListener('mouseout', mHideToolbar, false); | ||
|
||
gURLBar.removeEventListener('mouseout', mHideToolbar, false); | ||
|
||
gURLBar.removeEventListener('keydown', keyHide, false); | ||
}; | ||
|
||
AwesomeBookmarkbar.hideToolbar = function(e) { | ||
if (e.button == 2 || (e.button == 0 && !(e.metaKey || e.shiftKey || e.ctrlKey))) return; | ||
PersonalToolbar.collapsed = true; | ||
}; | ||
|
||
AwesomeBookmarkbar.cHideToolbar = function(e) { | ||
if (e.button == 0) { | ||
PersonalToolbar.collapsed = false; | ||
} | ||
}; | ||
|
||
AwesomeBookmarkbar.mShowToolbar = function(e) { | ||
PersonalToolbar.setAttribute('collapsed', 'false'); | ||
}; | ||
|
||
AwesomeBookmarkbar.mHideToolbar = function(e) { | ||
PersonalToolbar.setAttribute('collapsed', 'true'); | ||
}; | ||
|
||
AwesomeBookmarkbar.keyHide = function(e) { | ||
if (window.event ? e.keyCode : e.which) | ||
PTBar.collapsed = true; | ||
}, false); | ||
PersonalToolbar.collapsed = true; | ||
}; | ||
|
||
AwesomeBookmarkbar.init(); | ||
window.AwesomeBookmarkbar = AwesomeBookmarkbar; | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.