-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogle_search_layout.user.js
81 lines (57 loc) · 2.27 KB
/
google_search_layout.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
// ==UserScript==
// @name Make Google Search look normal in Firefox
// @version 1
// @grant None
// @include https://www.google.com/search*
// ==/UserScript==
// The catch tab needs to be offset to look correctly
var catch_tab_pad_size = "32px";
// Make the icon size smaller so it is not obnoxious
var icon_size = "10px";
// Currently the padding catch object is called yWc32e,
// this might change in the future but for now this works
var s_objects = document.getElementsByClassName('yWc32e');
// force the catch arrow down by the offset amount
for (var i = 0, len = s_objects.length; i < len; i++)
{
s_objects[i].style["padding-top"] = catch_tab_pad_size;
}
// Currently the icon object is called xA33Gc,
// this might change in the future but for now this works
var s_objects = document.getElementsByClassName('xA33Gc');
// make the icon smaller, We could remove this, but im ok with it smaller
for (var i = 0, len = s_objects.length; i < len; i++)
{
s_objects[i].style["width"] = icon_size;
s_objects[i].style["height"] = icon_size;
}
// At this point we need to invert the div and the H3 object to make things appear normally
// serach results are R, find them all
var r_objects = document.getElementsByClassName('r');
// cycle thru each R
for (var x = 0, len1 = r_objects.length; x < len1; x++)
{
// what we care about is in a A tag
var a_objects = r_objects[x].getElementsByTagName("a")
// cycle thru every a
for (var y = 0, len2 = a_objects.length; y < len2; y++)
{
// the cached button is busted in there layout atm, but lets skip if we find it.
if(a_objects[y].innerHTML=="Cached")
{
continue;
}
// any a node without a div or a h3 is not what we want.
if(a_objects[y].getElementsByTagName("div").length==0 || a_objects[y].getElementsByTagName("h3").length==0)
{
continue;
}
// at this point we have a good node, get the html for both the div and the h3.
var local_div = a_objects[y].getElementsByTagName("div")[0].outerHTML;
var local_h3 = a_objects[y].getElementsByTagName("h3")[0].outerHTML;
// rewrite the html with div below h3
a_objects[y].innerHTML = local_h3+"<br>"+local_div
// if we find the node no need to keep looking for it...
break
}
}