FIX for "Bing Search returns to the top" !

Stop doing weird things, Bing ! :)

当前为 2024-07-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name FIX for "Bing Search returns to the top" !
  3. // @namespace https://tampermonkey.net/FakerJMS
  4. // @version 0.1.0
  5. // @description Stop doing weird things, Bing ! :)
  6. // @author FakerJMS
  7. // @match http*://*.bing.com/*
  8. // @icon https://www.bing.com/sa/simg/favicon-trans-bg-blue-mg.ico
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 备份
  17. window._fk_scrollTo = window.scrollTo;
  18.  
  19. // 禁用"滚动到顶部"
  20. function disable_scrollToTop() {
  21. window.scrollTo = function(x, y) {
  22. if (y !== 0) {
  23. window._fk_scrollTo(x, y);
  24. }
  25. };
  26. }
  27.  
  28. // 使能"滚动到顶部"
  29. function _enable_scrollToTop(){
  30. window.scrollTo = window._fk_scrollTo;
  31. }
  32.  
  33. // 延时使能"滚动到顶部"
  34. function enable_scrollToTop() {
  35. setTimeout(_enable_scrollToTop, 2000);
  36. }
  37.  
  38. // 监听"获取焦点"事件
  39. window.addEventListener('focus', enable_scrollToTop);
  40. // 监听"失去焦点"事件
  41. window.addEventListener('blur', disable_scrollToTop);
  42. })();