Bing Simplify

Simplify the Bing

当前为 2024-06-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bing Simplify
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-06-22
  5. // @description Simplify the Bing
  6. // @license MIT
  7. // @author Sokranotes
  8. // @match *://*/*
  9. // @match https://cn.bing.com/*
  10. // @match https://www.bing.com/*
  11. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15.  
  16. // *://*/* to match the default new tab
  17. // ref: https://stackoverflow.com/questions/45300745/can-i-run-a-userscript-on-the-new-tab-page
  18.  
  19. function click(){
  20. //console.log("劫持click");
  21. document.querySelector('.sb_form_placeholder_query').setAttribute('style','display:none');
  22. document.getElementById('sa_hd').setAttribute('style','display:none');
  23. };
  24.  
  25. (function () {
  26. 'use strict';
  27. if((document.URL == 'https://cn.bing.com/chrome/newtab' || document.domain == 'cn.bing.com' || document.domain == 'bing.com') && document.title == '必应'){
  28. simplifyBingCN();
  29. }
  30. })();
  31.  
  32. function simplifyBingCN(){
  33. console.log("Simplify the Bing");
  34. document.getElementById('vs_cont').parentElement.setAttribute('style','display:none');
  35. document.getElementById('sb_form_q').addEventListener = click;
  36. document.getElementById('id_h').setAttribute('style','display:none');
  37. document.getElementById('images').setAttribute('style','display:none');
  38. document.getElementById('video').setAttribute('style','display:none');
  39. document.getElementById('dots_overflow_menu_container').setAttribute('style','display:none');
  40. document.getElementById('est_switch').setAttribute('style','display:none');
  41. //cleanSearch();
  42. }
  43.  
  44. function cleanSearch() {
  45. const el = document.querySelector('.SearchBar-input > input');
  46. const observer = new MutationObserver((mutationsList, observer) => {
  47. if (mutationsList[0].attributeName === 'placeholder' && mutationsList[0].target.placeholder != '') mutationsList[0].target.placeholder = '';
  48. });
  49. el.placeholder = '';
  50. observer.observe(el, { attributes: true });
  51. document.documentElement.appendChild(document.createElement('style')).textContent = '.AutoComplete-group > .SearchBar-label:not(.SearchBar-label--history), .AutoComplete-group > [id^="AutoComplete2-topSearch-"], .AutoComplete-group > [id^="AutoComplete3-topSearch-"] {display: none !important;}';
  52. }