FIX for "Bing Search returns to the top" !

Stop doing weird things, Bing ! ;)

  1. // ==UserScript==
  2. // @name FIX for "Bing Search returns to the top" !
  3. // @namespace http://tampermonkey.net/Henry
  4. // @version 1.0.1
  5. // @description Stop doing weird things, Bing ! ;)
  6. // @author Henry
  7. // @match http*://*.bing.com/*
  8. // @icon https://tsz.netlify.app/img/favicon.png
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. /*
  16. https://techcommunity.microsoft.com/t5/microsoft-bing/search-page-of-bing-automatically-jumping-to-the-top-of-page/m-p/3767178/emcs_t/S2h8ZW1haWx8dG9waWNfc3Vic2NyaXB0aW9ufExGN1BYSTdMVldJQkQxfDM3NjcxNzh8U1VCU0NSSVBUSU9OU3xoSw#M2615
  17.  
  18. So, I switched to Bing a month ago and.. I HAD the same problem, but I just fixed it !
  19.  
  20. There's a function in a script file triggered when Bing Search is Out of Focus, waiting for 15 seconds, and then Scroll the page to the top.
  21.  
  22. Why ? ... I really don't know ... but, who cares ? ;)
  23.  
  24. For Tampermonkey addon users on Chrome, Edge, Safari, Opera and Firefox, the simple way is to install a script like this.
  25.  
  26. AwayTimeThreshold defines the waiting time in seconds when the tab is no longer active to scroll up the page. (Default value: 15 seconds)
  27.  
  28. Some sort of temporary (but for a long time, i think ^^) solution is to set an impossible value to reach to this variable. (2 592 000 seconds = One month.)
  29.  
  30. I currently use this solution, and it works like a charm ! ;)
  31. */
  32. window.AwayTimeThreshold = 2_592_000;
  33.  
  34. /*
  35. // other solution
  36. // Disable the scroll to top functionality
  37. function disableScrollToTop() {
  38. window.scrollTo = function(x, y) {
  39. if (y !== 0) {
  40. window.scrollTo.originalFunc(x, y);
  41. }
  42. };
  43. window.scrollTo.originalFunc = window.scrollTo;
  44. }
  45.  
  46. // Listen for 'focus' events on the window
  47. window.addEventListener('focus', disableScrollToTop);
  48. */
  49. })();