Google Fixed Tab Order

Stops google from reordering the tabs like wtf are you doing you piece of shit, stolen from https://productforums.google.com/forum/#!topic/websearch/rWuCGv4OluA

  1. // ==UserScript==
  2. // @name Google Fixed Tab Order
  3. // @namespace google.com
  4. // @description Stops google from reordering the tabs like wtf are you doing you piece of shit, stolen from https://productforums.google.com/forum/#!topic/websearch/rWuCGv4OluA
  5. // @include https://www.google.com/search?*
  6. // @include https://www.google.com/webhp?*
  7. // @version 2.0
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function ()
  12. {
  13. var order = ["All", "Web", "Images", "Videos", "News", "Maps", "Books", "Apps", "Shopping", "Flights"];
  14.  
  15. function observerEnable()
  16. {
  17. observer.observe(document.querySelector("#main"), { childList: true, subtree: true });
  18. }
  19. function observerDisable()
  20. {
  21. observer.disconnect();
  22. }
  23. var observer = new MutationObserver(function(mutations)
  24. {
  25. observerDisable();
  26. fixTabs();
  27. observerEnable();
  28. });
  29. observerEnable();
  30. function fixTabs()
  31. {
  32. var parent = document.querySelector("#hdtb-msb");
  33. if (parent == null)
  34. return;
  35.  
  36. var tabs = parent.querySelectorAll(".hdtb-mitem");
  37.  
  38. var more = document.querySelector("#hdtb-more");
  39. var tools = document.querySelector("#hdtb-tls");
  40.  
  41. while (parent.firstChild)
  42. parent.removeChild(parent.firstChild);
  43.  
  44. for (var i = 0; i < order.length; i++)
  45. for (var t = 0; t < tabs.length; t++)
  46. if (order[i] == tabs[t].textContent)
  47. parent.appendChild(tabs[t]);
  48. parent.appendChild(tools);
  49. }
  50. fixTabs();
  51. })();