Greasy Fork is available in English.

Search Align Fucker (simple impl) - Search Results Centering Script

A simple implementation of moving search result to page center or anywhere for both Google and Bing. support new bing chat also . (the resize bar is hiddenn on left)

  1. // ==UserScript==
  2. // @name Search Align Fucker (simple impl) - Search Results Centering Script
  3. // @version 0.0.3.2
  4. // @author Heizi黑字
  5. // @description A simple implementation of moving search result to page center or anywhere for both Google and Bing. support new bing chat also . (the resize bar is hiddenn on left)
  6. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  7. // @grant GM.setValue
  8. // @grant GM.getValue
  9. // @icon64 https://cdn.jsdelivr.net/gh/ElisaMin/justify-search-page-to-center/logo.png
  10. // @match https://www.bing.com/search*
  11. // @match https://www.google.com/search*
  12. // @match https://cn.bing.com/search*
  13. // @match https://www.google.*/search*
  14. // @match https://(www\.|cn\.)?(google|bing)\.(.+)/search\?.+
  15. // @match https://www.google.com/search*
  16. // @match https://www.google.ad/search*
  17. // @match https://www.google.ae/search*
  18. // @match https://www.google.com.af/search*
  19. // @match https://www.google.com.ag/search*
  20. // @match https://www.google.com.ai/search*
  21. // @match https://www.google.al/search*
  22. // @match https://www.google.am/search*
  23. // @match https://www.google.co.ao/search*
  24. // @match https://www.google.com.ar/search*
  25. // @match https://www.google.as/search*
  26. // @match https://www.google.at/search*
  27. // @match https://www.google.com.au/search*
  28. // @match https://www.google.az/search*
  29. // @match https://www.google.ba/search*
  30. // @match https://www.google.com.bd/search*
  31. // @match https://www.google.be/search*
  32. // @match https://www.google.bf/search*
  33. // @match https://www.google.bg/search*
  34. // @match https://www.google.com.bh/search*
  35. // @match https://www.google.bi/search*
  36. // @match https://www.google.bj/search*
  37. // @match https://www.google.com.bn/search*
  38. // @match https://www.google.com.bo/search*
  39. // @match https://www.google.com.br/search*
  40. // @match https://www.google.bs/search*
  41. // @match https://www.google.bt/search*
  42. // @match https://www.google.co.bw/search*
  43. // @match https://www.google.by/search*
  44. // @match https://www.google.com.bz/search*
  45. // @match https://www.google.ca/search*
  46. // @match https://www.google.cd/search*
  47. // @match https://www.google.cf/search*
  48. // @match https://www.google.cg/search*
  49. // @match https://www.google.ch/search*
  50. // @match https://www.google.ci/search*
  51. // @match https://www.google.co.ck/search*
  52. // @match https://www.google.cl/search*
  53. // @match https://www.google.cm/search*
  54. // @match https://www.google.cn/search*
  55. // @match https://www.google.com.co/search*
  56. // @match https://www.google.co.cr/search*
  57. // @match https://www.google.com.cu/search*
  58. // @match https://www.google.cv/search*
  59. // @match https://www.google.com.cy/search*
  60. // @match https://www.google.cz/search*
  61. // @match https://www.google.de/search*
  62. // @match https://www.google.dj/search*
  63. // @match https://www.google.dk/search*
  64. // @match https://www.google.dm/search*
  65. // @match https://www.google.com.do/search*
  66. // @match https://www.google.dz/search*
  67. // @match https://www.google.com.ec/search*
  68. // @match https://www.google.ee/search*
  69. // @match https://www.google.com.eg/search*
  70. // @match https://www.google.es/search*
  71. // @match https://www.google.com.et/search*
  72. // @match https://www.google.fi/search*
  73. // @match https://www.google.com.fj/search*
  74. // @match https://www.google.fm/search*
  75. // @match https://www.google.fr/search*
  76. // @match https://www.google.ga/search*
  77. // @match https://www.google.ge/search*
  78. // @match https://www.google.gg/search*
  79. // @match https://www.google.com.gh/search*
  80. // @match https://www.google.com.gi/search*
  81. // @match https://www.google.gl/search*
  82. // @match https://www.google.gm/search*
  83. // @match https://www.google.gr/search*
  84. // @match https://www.google.com.gt/search*
  85. // @match https://www.google.gy/search*
  86. // @match https://www.google.com.hk/search*
  87. // @match https://www.google.hn/search*
  88. // @match https://www.google.hr/search*
  89. // @match https://www.google.ht/search*
  90. // @match https://www.google.hu/search*
  91. // @match https://www.google.co.id/search*
  92. // @match https://www.google.ie/search*
  93. // @match https://www.google.co.il/search*
  94. // @match https://www.google.im/search*
  95. // @match https://www.google.co.in/search*
  96. // @match https://www.google.iq/search*
  97. // @match https://www.google.is/search*
  98. // @match https://www.google.it/search*
  99. // @match https://www.google.je/search*
  100. // @match https://www.google.com.jm/search*
  101. // @match https://www.google.jo/search*
  102. // @match https://www.google.co.jp/search*
  103. // @match https://www.google.co.ke/search*
  104. // @match https://www.google.com.kh/search*
  105. // @match https://www.google.ki/search*
  106. // @match https://www.google.kg/search*
  107. // @match https://www.google.co.kr/search*
  108. // @match https://www.google.com.kw/search*
  109. // @match https://www.google.kz/search*
  110. // @match https://www.google.la/search*
  111. // @match https://www.google.com.lb/search*
  112. // @match https://www.google.li/search*
  113. // @match https://www.google.lk/search*
  114. // @match https://www.google.co.ls/search*
  115. // @match https://www.google.lt/search*
  116. // @match https://www.google.lu/search*
  117. // @match https://www.google.lv/search*
  118. // @match https://www.google.com.ly/search*
  119. // @match https://www.google.co.ma/search*
  120. // @match https://www.google.md/search*
  121. // @match https://www.google.me/search*
  122. // @match https://www.google.mg/search*
  123. // @match https://www.google.mk/search*
  124. // @match https://www.google.ml/search*
  125. // @match https://www.google.com.mm/search*
  126. // @match https://www.google.mn/search*
  127. // @match https://www.google.ms/search*
  128. // @match https://www.google.com.mt/search*
  129. // @match https://www.google.mu/search*
  130. // @match https://www.google.mv/search*
  131. // @match https://www.google.mw/search*
  132. // @match https://www.google.com.mx/search*
  133. // @match https://www.google.com.my/search*
  134. // @match https://www.google.co.mz/search*
  135. // @match https://www.google.com.na/search*
  136. // @match https://www.google.com.ng/search*
  137. // @match https://www.google.com.ni/search*
  138. // @match https://www.google.ne/search*
  139. // @match https://www.google.nl/search*
  140. // @match https://www.google.no/search*
  141. // @match https://www.google.com.np/search*
  142. // @match https://www.google.nr/search*
  143. // @match https://www.google.nu/search*
  144. // @match https://www.google.co.nz/search*
  145. // @match https://www.google.com.om/search*
  146. // @match https://www.google.com.pa/search*
  147. // @match https://www.google.com.pe/search*
  148. // @match https://www.google.com.pg/search*
  149. // @match https://www.google.com.ph/search*
  150. // @match https://www.google.com.pk/search*
  151. // @match https://www.google.pl/search*
  152. // @match https://www.google.pn/search*
  153. // @match https://www.google.com.pr/search*
  154. // @match https://www.google.ps/search*
  155. // @match https://www.google.pt/search*
  156. // @match https://www.google.com.py/search*
  157. // @match https://www.google.com.qa/search*
  158. // @match https://www.google.ro/search*
  159. // @match https://www.google.ru/search*
  160. // @match https://www.google.rw/search*
  161. // @match https://www.google.com.sa/search*
  162. // @match https://www.google.com.sb/search*
  163. // @match https://www.google.sc/search*
  164. // @match https://www.google.se/search*
  165. // @match https://www.google.com.sg/search*
  166. // @match https://www.google.sh/search*
  167. // @match https://www.google.si/search*
  168. // @match https://www.google.sk/search*
  169. // @match https://www.google.com.sl/search*
  170. // @match https://www.google.sn/search*
  171. // @match https://www.google.so/search*
  172. // @match https://www.google.sm/search*
  173. // @match https://www.google.sr/search*
  174. // @match https://www.google.st/search*
  175. // @match https://www.google.com.sv/search*
  176. // @match https://www.google.td/search*
  177. // @match https://www.google.tg/search*
  178. // @match https://www.google.co.th/search*
  179. // @match https://www.google.com.tj/search*
  180. // @match https://www.google.tl/search*
  181. // @match https://www.google.tm/search*
  182. // @match https://www.google.tn/search*
  183. // @match https://www.google.to/search*
  184. // @match https://www.google.com.tr/search*
  185. // @match https://www.google.tt/search*
  186. // @match https://www.google.com.tw/search*
  187. // @match https://www.google.co.tz/search*
  188. // @match https://www.google.com.ua/search*
  189. // @match https://www.google.co.ug/search*
  190. // @match https://www.google.co.uk/search*
  191. // @match https://www.google.com.uy/search*
  192. // @match https://www.google.co.uz/search*
  193. // @match https://www.google.com.vc/search*
  194. // @match https://www.google.co.ve/search*
  195. // @match https://www.google.vg/search*
  196. // @match https://www.google.co.vi/search*
  197. // @match https://www.google.com.vn/search*
  198. // @match https://www.google.vu/search*
  199. // @match https://www.google.ws/search*
  200. // @match https://www.google.rs/search*
  201. // @match https://www.google.co.za/search*
  202. // @match https://www.google.co.zm/search*
  203. // @match https://www.google.co.zw/search*
  204. // @match https://www.google.cat/search*
  205. // @run-at document-start
  206. // @supportURL https://github.com/ElisaMin/justify-search-page-to-center
  207. // @homepageURL https://github.com/ElisaMin/justify-search-page-to-center
  208. // @name:zh-CN 居中啊!他娘的搜索引擎!
  209. // @description:zh-CN 简单加点padding把搜索结果移到中间。(可调节, 移动鼠标到边界处可见)
  210. // @namespace https://greasyfork.org/users/1018732
  211. // ==/UserScript==
  212.  
  213. let css = (selector) => {
  214. let css = "";
  215. css += "#resizerbar:hover {"
  216. css += "box-shadow: 0 0 1px;"
  217. css += "}"
  218. css += "#resizerbar {"
  219. css += "position: fixed;left: var(--content-shift-size);"
  220. css += "width: 10px;height: 100vh;"
  221. css += "cursor: col-resize;z-index: 125;"
  222. css += "}"
  223. css += selector+ " {"
  224. css += "padding-left:var(--content-shift-size);"
  225. css += "}"
  226. return css
  227. }
  228. let getSize = (key,defVal)=> GM.getValue(key+"_search_page_shift_size",(!!defVal)?defVal:"45rem")
  229. let currentPage = ""
  230. currentPage = location.hostname.indexOf("google")>0 // is Google
  231. currentPage = {
  232. key:currentPage?"google":"bing",
  233. size:await (currentPage?getSize("google","30rem"):getSize("bing","43rem")),
  234. cssSelector:currentPage
  235. ?"#hdtb-msb,#result-stats,#rcnt,#tsf,.aAbqZ"
  236. :"#resizerbar {border-left: 1px solid #ddd;}#b_header,#b_content,#b_sydConvCont",
  237. }
  238. if(!isNaN(currentPage.size)) {
  239. currentPage.size += "px"
  240. }
  241. css="body{--content-shift-size:"+currentPage.size+"}"+css(currentPage.cssSelector)
  242. if (currentPage.key=="bing") {
  243. css += "#b_content {margin-left:160px;}"
  244. }
  245. if(!$) var $ = (slt) => document.querySelector(slt)
  246. let elm
  247. elm = document.createElement("style")
  248. elm.innerText = css
  249. $("head").appendChild(elm)
  250. window.onload = ()=>{
  251. const elm = document.createElement("span")
  252. elm.id = "resizerbar"
  253.  
  254. elm.onmouseup=(event) => {
  255. elm.isDragging = false;
  256. }
  257. elm.onmousedown=(event) => {
  258. elm.isDragging = true;
  259. }
  260. let body = document.body
  261. body.onmousemove=(event) => {
  262. if(elm.isDragging) {
  263. let shift = event.pageX
  264. $("#resizerbar").style.left = shift+"px"
  265. GM.setValue(currentPage.key+"_search_page_shift_size",shift)
  266. document.body.style.setProperty("--content-shift-size",shift+"px")
  267. }
  268. }
  269. body.insertBefore(elm,body.firstChild)
  270. }