Googlifix

Fixes layout of Google if you don't like 2012 and 2013 changes. Brings back left column (sidebar) options, all expanded, black bar, etc.

  1. // ==UserScript==
  2. // @name Googlifix
  3. // @author om467
  4. // @namespace com.googlifix
  5. // @include http://www.google.tld/search*
  6. // @include https://www.google.tld/search*
  7. // @include http://www.google.tld/webhp*
  8. // @include https://www.google.tld/webhp*
  9. // @include http://google.tld/search*
  10. // @include https://google.tld/search*
  11. // @include http://google.tld/webhp*
  12. // @include https://google.tld/webhp*
  13. // @include http://www.google.tld/
  14. // @include https://www.google.tld/
  15. // @include http://google.tld/
  16. // @include https://google.tld/
  17. // @include http://www.google.tld/#*
  18. // @include https://www.google.tld/#*
  19. // @include http://google.tld/#*
  20. // @include https://google.tld/#*
  21. // @include http://www.google.tld/?*
  22. // @include https://www.google.tld/?*
  23. // @include http://google.tld/?*
  24. // @include https://google.tld/?*
  25. // @include https://encrypted.google.com/search*
  26. // @include https://encrypted.google.com/webhp*
  27. // @include https://encrypted.google.com/
  28. // @include https://encrypted.google.com/#*
  29. // @version 29
  30. // @grant GM_addStyle
  31. // @grant GM_getValue
  32. // @grant GM_setValue
  33. // @grant GM_xmlhttpRequest
  34. // @description Fixes layout of Google if you don't like 2012 and 2013 changes. Brings back left column (sidebar) options, all expanded, black bar, etc.
  35. // ==/UserScript==
  36.  
  37. (function ()
  38. {
  39. // Constants
  40. var MUTATION_OBSERVER = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  41. var SCRIPT_VERSION = 29;
  42. var UPDATE_CHECK_INTERVAL = 172800; // 2 days
  43. var UPDATE_CHECK_DELAY = 2000;
  44.  
  45. // Styles
  46. GM_addStyle(" \
  47. /* left sidebar */ \
  48. #hdtbMenus {overflow:visible !important; display:block !important;} \
  49. #hdtbMenus > div > div {display:none;} \
  50. #hdtbMenus > div > ul {display:block !important; margin-top:15px; min-width:150px !important; width:180px; border:0px !important; box-shadow:none !important; left:10px !important; top:50px !important; position:relative !important;} \
  51. @media screen and (min-width: 1400px){ \
  52. #hdtbMenus > div > ul {width:250px;} \
  53. } \
  54. #sc-block {width:120px !important; white-space:normal !important; height:auto !important;} \
  55. #sc-block .sc {display:inline-block !important; float:none !important;} \
  56. .hdtbItm.hdtbSel, \
  57. #hdtb .hdtbItm a, \
  58. #hdtb_more_mn a, \
  59. #cdrlnk {text-overflow:ellipsis !important; overflow:hidden !important; padding-right:4px !important;} \
  60. \
  61. /* content */ \
  62. #main #cnt #center_col, \
  63. .ab_tnav_wrp, \
  64. .mw #center_col, \
  65. .mw #foot {margin-left:197px !important;} \
  66. @media screen and (min-width: 1400px){ \
  67. #main #cnt #center_col, \
  68. .ab_tnav_wrp, \
  69. .mw #center_col, \
  70. .mw #foot {margin-left:267px !important;} \
  71. } \
  72. .mw #rhscol {overflow:visible !important;} \
  73. html.com-googlifix #center_col {min-height:550px;} \
  74. html.com-googlifix.com-googlifix-domain #center_col, html.com-googlifix.com-googlifix-uilanguage #center_col {min-height:800px;} \
  75. html.com-googlifix.com-googlifix-domain.com-googlifix-uilanguage #center_col {min-height:1000px;} \
  76. \
  77. /* top bar with menu */ \
  78. #hdtb_msb > .hdtb_mitem:first-child, \
  79. #hdtb_msb > .hdtb_mitem.hdtb_msel:first-child {margin-left:210px !important;} \
  80. @media screen and (min-width: 1400px){ \
  81. #hdtb_msb > .hdtb_mitem:first-child, \
  82. #hdtb_msb > .hdtb_mitem.hdtb_msel:first-child {margin-left:280px !important;} \
  83. } \
  84. #hdtb_tls {display:none !important;} \
  85. #hdtb_more {display:none !important;} \
  86. #hdtb_more_mn {display:inline-block !important; top:0px; border:0px !important; box-shadow:none !important; background-color:transparent !important; height:54px; overflow:hidden; margin-right:15px; padding:0px; position:relative !important;} \
  87. #hdtb_more_mn div.hdtb_msb_hmi {display:inline-block;} \
  88. #hdtb_more_mn div.hdtb_mitem {float:left;} \
  89. #hdtb_more_mn > div.hdtb_mitem:last-child, \
  90. #hdtb_more_mn > div.hdtb_mitem:nth-last-child(2) {display:none !important;} \
  91. @media screen and (min-width: 1400px){ \
  92. #hdtb_more_mn > div.hdtb_mitem:last-child, \
  93. #hdtb_more_mn > div.hdtb_mitem:nth-last-child(2) {display:inline-block !important;} \
  94. } \
  95. #hdtb_more_mn div.hdtb_mitem > a {height:44px; line-height:44px; padding:0 8px !important; margin:0 8px; display:inline-block;} \
  96. #hdtb_more_mn div.hdtb_mitem > a.q.qs:hover {background-color:transparent; color:#222 !important;} \
  97. #hdtb_msb > div.hdtb_mitem, \
  98. #hdtb_more_mn {vertical-align:middle; height:44px; line-height:44px;} \
  99. li.hdtbItm input[type='text'] {max-width:60px;} \
  100. li.hdtbItm input[type='submit'] {max-width:60px;} \
  101. @media screen and (min-width: 1400px){ \
  102. li.hdtbItm input[type='text'] {max-width:initial;} \
  103. li.hdtbItm input[type='submit'] {max-width:initial;} \
  104. } \
  105. body.vasq #hdtb_msb > div.hdtb_mitem.hdtb_msel {height:44px;} \
  106. #hdtb #hdtbSum {height:49px; line-height:44px;} \
  107. #topabar {border-bottom:1px solid #EBEBEB !important;} \
  108. #tads {padding-right:0px !important;} \
  109. \
  110. /* right profile box */ \
  111. #rhs_block > div, \
  112. #rhs_block > li, \
  113. #rhs_block > ol {margin-left:65px !important;} \
  114. @media screen and (min-width: 1400px){ \
  115. #rhs_block > div, \
  116. #rhs_block > li, \
  117. #rhs_block > ol {margin-left:145px !important;} \
  118. } \
  119. \
  120. /* people also search */ \
  121. #botabar {margin-left:280px !important;} \
  122. \
  123. /* images search */ \
  124. #main #cnt {background-color:#fff;} \
  125. #isr_soa {width:99% !important;} \
  126. div.prcmg {border-color:transparent;} \
  127. div#ifbd {background-color:transparent;} \
  128. \
  129. /* images search detail */ \
  130. iframe.irc_ifr {width:100% !important;} \
  131. #irc_bg {left:213px !important;} \
  132. @media screen and (min-width: 1400px){ \
  133. #irc_bg {left:283px !important;} \
  134. } \
  135. div.irc_t {width:62% !important; overflow:hidden;} \
  136. div.irc_b {min-width:auto;} \
  137. div.irc_cpr {display:none;} \
  138. \
  139. /* search bar + logo + black bar */ \
  140. #gba {height:57px;} \
  141. #gb > div > #gbq1 {margin-left:80px !important; padding-right:0px;} \
  142. @media screen and (min-width: 1400px){ \
  143. #gb > div > #gbq1 {margin-left:150px !important;} \
  144. } \
  145. #gb.com-googlifix-blackbar-searchbar {top:30px;} \
  146. #com-googlifix-blackbar {background-color:#444; padding:0px; height:30px; width:auto;} \
  147. #com-googlifix-blackbar a { display:inline-block; height:30px; line-height:30px; cursor:pointer; margin:0px; padding:0px 10px; text-decoration:none; color:#fff; font-weight:bold;} \
  148. #com-googlifix-blackbar a:hover {background-color:#666;} \
  149. #gbwa {display:none;} \
  150. \
  151. /* settings button + account button */ \
  152. #ab_ctls {z-index:103 !important; padding-bottom:4px !important; padding-right:16px !important; right:0px !important; background-color:transparent !important;} \
  153. #gbu.gbu-low-res {left:890px !important; right:auto;} \
  154. \
  155. /* footer */ \
  156. #fbarcnt {max-height:40px;} \
  157. #fbarcnt > div {bottom:auto;} \
  158. div.fbar {min-width:300px; border-bottom:1px solid #E4E4E4;} \
  159. \
  160. /* update box */ \
  161. #com-googlifix-updatebox {z-index:10000; background-color:#FFFFFF; border:1px solid #C5C5C5; box-shadow:0px 4px 16px rgba(0, 0, 0, 0.2); padding:10px 20px; position:fixed; top:10px; right:100px; color:#dd4b39; font-size:14px; font-weight:bold; } \
  162. ");
  163. // black bar
  164. var blackbarItems = document.querySelectorAll("#gbwa > :nth-child(2) > ul");
  165. if (blackbarItems.length > 0 && document.location.host != "encrypted.google.com")
  166. {
  167. // search bar
  168. document.querySelector("#gb").className += " com-googlifix-blackbar-searchbar";
  169. // blackbar wrapper
  170. var blackbarWrapper = document.createElement("div");
  171. blackbarWrapper.setAttribute("id", "com-googlifix-blackbar");
  172. document.querySelector("#mngb").insertBefore(blackbarWrapper, document.querySelector("#gb"));
  173. // service links
  174. var serviceLinks = document.querySelectorAll("#gbwa > :nth-child(2) li");
  175. for (var i = 0; i < serviceLinks.length; i++)
  176. {
  177. var link = serviceLinks[i];
  178. var blackbarLink = document.createElement("a");
  179. blackbarLink.innerHTML = link.querySelector("a > :nth-child(2)").innerHTML;
  180. blackbarLink.setAttribute("href", link.querySelector("a").getAttribute("href"));
  181. blackbarWrapper.appendChild(blackbarLink);
  182. }
  183. // more link
  184. var moreLink = document.querySelector("#gbwa > :nth-child(2) > a:nth-of-type(2)");
  185. moreLink.className = "";
  186. blackbarWrapper.appendChild(moreLink);
  187. }
  188. // Images - Results width fix
  189. if (document.location.search.indexOf("tbm=isch") != -1 || document.location.hash.indexOf("tbm=isch") != -1)
  190. {
  191. // content width
  192. var rgObserver = new MUTATION_OBSERVER(function(mutations)
  193. {
  194. // width
  195. mutations[0].target.style.width = parseInt(getComputedStyle(document.querySelector("#rso"), "").getPropertyValue("width")) + "px";
  196.  
  197. // google recalculates everything on window resize, so we help him to know that there was a change by GM
  198. setTimeout(function()
  199. {
  200. var uiEvent = document.createEvent('UIEvents');
  201. uiEvent.initUIEvent('resize', true, false, window, 0);
  202. window.dispatchEvent(uiEvent);
  203. }, 1000);
  204. rgObserver.disconnect();
  205. });
  206. rgObserver.observe(document.querySelector("#rg"), { attributes: true, childList: false, attributeFilter: ["style"] });
  207.  
  208. // image detail width
  209. var ircObserver = new MUTATION_OBSERVER(function(mutations)
  210. {
  211. for (var i = 0; i < mutations.length; i++)
  212. {
  213. if ((mutations[i].target.id || "") == "rcnt")
  214. {
  215. var ircc = document.querySelectorAll("div.irc_c");
  216. var rg = document.querySelector("#rg");
  217. if (ircc.length == 3 && rg != null)
  218. {
  219. var rgWidth = (parseInt(getComputedStyle(rg, null).getPropertyValue("width")) - 12) + "px";
  220. mutations[i].addedNodes[0].style.maxWidth = rgWidth;
  221. for (var k = 0; k < ircc.length; k++)
  222. ircc[k].style.maxWidth = rgWidth;
  223. }
  224. return;
  225. }
  226. }
  227. });
  228. ircObserver.observe(document.querySelector("#main"), { attributes: false, childList: true, subtree: true });
  229. }
  230. // Adds class to HTML element for compatibility reasons, so that other userscripts know about this userscript
  231. document.querySelector("html").className += " com-googlifix";
  232. // update check
  233. function openUpdateDialog()
  234. {
  235. var box = document.createElement("div");
  236. box.id = "com-googlifix-updatebox";
  237. box.innerHTML = "New version of Googlifix is available. <a href=\"http://userscripts.org/scripts/source/152777.user.js\" onclick=\"this.parentNode.style.display='none'\">Update now</a>.";
  238. document.querySelector("body").appendChild(box);
  239. }
  240. setTimeout(function()
  241. {
  242. var lastUpdateCheck = GM_getValue('lastCheck', 0);
  243. var lastCheckVersion = GM_getValue('lastCheckVersion', SCRIPT_VERSION);
  244. var now = Math.round(new Date().getTime() / 1000);
  245. if (now > (lastUpdateCheck + UPDATE_CHECK_INTERVAL))
  246. {
  247. GM_setValue('lastCheck', now);
  248. GM_xmlhttpRequest({
  249. method: "GET",
  250. url: "http://userscripts.org/scripts/source/152777.meta.js",
  251. onload: function(xhr)
  252. {
  253. var siteVersion = parseInt(xhr.responseText.match(/\/\/\s*@version\s*([\d]+).*/)[1]);
  254. GM_setValue('lastCheckVersion', siteVersion);
  255. if (siteVersion > SCRIPT_VERSION)
  256. openUpdateDialog();
  257. }
  258. });
  259. }
  260. else if (SCRIPT_VERSION < lastCheckVersion)
  261. openUpdateDialog();
  262. }, UPDATE_CHECK_DELAY);
  263. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址