/
gmail_flm.user.js
196 lines (178 loc) · 5.85 KB
/
gmail_flm.user.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// Google GMAIL Fixed Left Menu + Search
// version 0.42 BETA!
// 30-10-2005
// Copyright (c) 2005, Michael Pritchard
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Google GMAIL Fixed Left Menu + Search", and click Uninstall.
//
// Made thanks to http://diveintogreasemonkey.org/
// and also thanks to gmail-smart-delete-button (or previous), http://smart-delete-button.blogspot.com/.
// The code there helped me fix the 'reloading bug'
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Google GMAIL Fixed Left Menu + Search
// @namespace http://www.blueghost.co.uk/gmail_flm.html
// @description Fixes the Left Menu + Top Navigation Bar in Place
// @include http*://*mail.google.com/*mail/*
// ==/UserScript==
(function(){
//copies the search query to the top search box
window._gm_fillSBox = function(){
var sb = document.getElementById('ss_box');
var rb = document.getElementsByTagName('input');
for (var i=0; i <rb.length; i++){
if (rb[i].name == 'q'){
rb[i].value= sb.value;
return;
}
}
}
//fixes chevron pointing to emails in folders
window._gm_fixChevron = function(){
//not yet implemented
}
window._gm_unFixer = function(){
}
//fixes the left menu and adds the search box+button
window._gm_fixLeftMenu = function(){
var menu = document.getElementById('nav');
if (menu !=null){
menu.style.position = "fixed";
}
var l_m = document.getElementById('in');
if (l_m == null){/*try again???*/
l_m = document.getElementById('nb_1');
}
var label_menu = document.getElementById('nb_0');
if (label_menu !=null){
var f_link = document.createElement('div');
f_link.id = '_gm_side_bar_fixer';
label_menu.parentNode.insertBefore(f_link, label_menu.previousSibling);
}
if (l_m != null){
var s_form = document.createElement('div');
s_form.id = '_gm_side_bar_search';
s_form.innerHTML = '<form id="s_2" class="s" style="padding-bottom: 5px; white-space: nowrap;" onsubmit="return top.js._MH_OnSearch(window,0)">'+
'<input style="width: 100%;" maxlength="2048" id="ss_box" name="q_2" value=""><br/>'+
'<input value="Search Mail" onclick="javascript:_gm_fillSBox();" type="submit">'+
'</form>';
l_m.parentNode.insertBefore(s_form, l_m.nextSibling);
}
};
//fixes the top menu
window._gm_fixTopMenu = function (){
var t = document.getElementById('tc_top');
if (t != null){/*LOOKING AT INBOX/FOLDER*/
t.style.position = "fixed";
}else{/*VIEWING MAIL*/
var tbl = document.getElementsByTagName('table');
for (var i=0; i <tbl.length; i++){
if (tbl[i].className == 'th'){ /*GET FIRST TABLE LIKE THIS ONLY*/
tbl[i].style.position = "fixed";
//tbl[i].style.zIndex = "10000";
i = tbl.length;
}
}
//move right hand side across
var sps = document.getElementsByTagName('span');
for (var i=0; i <sps.length; i++){
if (sps[i].className == 'roz'){
sps[i].style.position = "fixed;";
sps[i].style.right = "5px;";
i = sps.length;
}
}
}
var et = document.getElementById('fi');
if (et != null){/*READING EMAIL*/
et.style.padding = "2em 26ex 0pt 8px";
}else{/*LOOKING AT A FOLDER*/
var tb = document.getElementById('tb');
if (tb != null){
tb.style.margin = "3em 0px 0px 0px";
}
}
//fixes the adbar
var adbar = document.getElementById('rh');
if (adbar !=null){/*then in email, hence ads*/
adbar.style.position = "fixed;";
//adbar.style.top = "100px";
adbar.style.margin = "3em 0px 0px 0px";
//adbar.style.zIndex = "50";
}
};
//thanks to gmail-smart-delete-button (or previous), http://smart-delete-button.blogspot.com/
window._gm_initHandlers = function(){
if (window.captureEvents) {
window.addEventListener('click', _gm_ProcessEvent,false);
window.addEventListener('keypress', _gm_ProcessKeyPressEvent,false);
window.addEventListener('focus', _gm_ProcessEvent,false);
window.addEventListener('blur', _gm_ProcessEvent,false);
}
};
window._gm_validateControls = function(){
var s_form = document.getElementById('_gm_side_bar_search');
if (!s_form){
_gm_fixLeftMenu();
_gm_fixTopMenu();
_gm_fixChevron();
}
};
//thanks to gmail-smart-delete-button (or previous), http://smart-delete-button.blogspot.com/
window._gm_ProcessEvent = function _gm_ProcessEvent(e)
{
try{
if (!e) var e = window.event;
var strTarget = e.target;
//Let gmail's code run first...
var retval = routeEvent(e);
//Wait for the page to redisplay then revalidate...
_gm_validateControls();
setTimeout("_gm_validateControls()", 500);
setTimeout("_gm_validateControls()", 2000);
setTimeout("_gm_validateControls()", 4000);
setTimeout("_gm_validateControls()", 8000);
setTimeout("_gm_validateControls()", 16000);
//call smart-delete
if (ProcessEvent)
ProcessEvent(e);
if (retval == false) return false;
else return true;
} catch(e) {
//GM_log("[ProcessEvent]: " + e);
}
};
//thanks to gmail-smart-delete-button (or previous), http://smart-delete-button.blogspot.com/
window._gm_ProcessKeyPressEvent = function _gm_ProcessKeyPressEvent(e)
{
try{
if (!e) var e = window.event;
var retval = routeEvent(e);
//First call out generic event handler to validate controls...
_gm_ProcessEvent(e);
if (ProcessKeyPressEvent)
ProcessKeyPressEvent(e);
if (retval == false) return false;
else return true;
} catch(e) {
//GM_log("[ProcessKeyPressEvent]: " + e);
}
};
_gm_initHandlers();
_gm_fixLeftMenu();
_gm_fixTopMenu();
})()