-
Notifications
You must be signed in to change notification settings - Fork 123
/
OpenSearchNotification.uc.js
65 lines (58 loc) · 2.06 KB
/
OpenSearchNotification.uc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// ==UserScript==
// @name OpenSearchNotification.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Open Search Notification
// @include main
// @compatibility Firefox 4.0
// @author Alice0775
// @Note
// @version 2012/12/08 22:30 Bug 788290 Bug 788293 Remove E4X
// ==/UserScript==
// @version 2011/01/31 13:00 Minefield/3.7a4pre Bug 554991 - allow tab context menu to be modified by normal XUL overlays
var osglow = {
init: function() {
var style = " \
.searchbar-engine-button[addengines='true'] .searchbar-dropmarker-image { \
background-image: -moz-radial-gradient(center 45deg, highlight 0%, rgba(255,255,255,0) 100%) !important; \
}";
var sspi = document.createProcessingInstruction(
'xml-stylesheet',
'type="text/css" href="data:text/css,' + encodeURIComponent(style) + '"'
);
document.insertBefore(sspi, document.documentElement);
sspi.getAttribute = function(name) {
return document.documentElement.getAttribute(name);
};
gBrowser.addEventListener("pageshow", this, false);
gBrowser.mTabContainer.addEventListener("select", this, false);
window.addEventListener("unload", this, false);
},
uninit: function() {
window.removeEventListener("unload", this, false);
gBrowser.removeEventListener("pageshow", this, false);
gBrowser.mTabContainer.removeEventListener("select", this, false);
},
timer: null,
handleEvent: function(event) {
switch (event.type) {
case 'pageshow':
case 'select':
if (this.timer)
clearTimeout(this.timer);
this.timer = setTimeout(function(self){self.osupdate();}, 0, this);
break;
case 'unload':
this.uninit();
break;
}
},
osupdate: function() {
var engines = gBrowser.selectedBrowser.engines;
var search = document.getElementById("searchbar");
if (engines && engines.length > 0)
search.searchButton.setAttribute("addengines", "true");
else
search.searchButton.removeAttribute("addengines");
}
}
osglow.init();