Better Bing

A better Bing experience

  1. // ==UserScript==
  2. // @name Better Bing
  3. // @namespace feifeihang.info
  4. // @description A better Bing experience
  5. // @include *.bing.com/search*
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9. (function (window, document, undefined) {
  10. var COLORS = [
  11. '#FFFF00',
  12. '#CCCCFF',
  13. '#00CCFF',
  14. '#33CCCC',
  15. '#FF8080',
  16. '#FFCC00',
  17. '#008000',
  18. '#FFFF99',
  19. '#808000',
  20. '#FFFFCC'
  21. ];
  22. // find all <strong> for highlighting
  23. var strongs = document.querySelectorAll('strong');
  24. var count = 0;
  25. var style = {
  26. };
  27. strongs = Array.prototype.slice.apply(strongs);
  28. strongs.map(function (strong) {
  29. var item = strong.textContent;
  30. if (style[item]) {
  31. strong.style.background = style[item];
  32. strong.style.color = '#000';
  33. strong.style.fontWeight = 'bold';
  34. }
  35. else {
  36. style[item] = COLORS[count++];
  37. if (count >= COLORS.length) {
  38. count = 0;
  39. }
  40. strong.style.background = style[item];
  41. strong.style.color = '#000';
  42. strong.style.fontWeight = 'bold';
  43. }
  44. });
  45. // add top button.
  46. var btn = document.createElement('div');
  47. btn.id = 'better-bing-top-btn';
  48. btn.style = 'display: none; border-radius: 100%; position: fixed; bottom: 20px; right: 20px;' +
  49. 'height: 50px; width: 50px; line-height: 50px; color: #fff; background: #CC0000;' +
  50. 'cursor: pointer; text-align: center; text-weight: bold; box-shadow: 0 2px 5px grey;';
  51. btn.textContent = 'TOP';
  52. btn.onclick = function () {
  53. window.scrollTo(0, 0);
  54. };
  55. document.body.appendChild(btn);
  56. window.addEventListener('scroll', function () {
  57. if (window.pageYOffset >= 30) {
  58. document.querySelector('#better-bing-top-btn').style.display = 'block';
  59. }
  60. else {
  61. document.querySelector('#better-bing-top-btn').style.display = 'none';
  62. }
  63. });
  64. // remove annoying right context contents.
  65. var context = document.querySelector('#b_context');
  66. if (context) {
  67. context.remove();
  68. }
  69. // remove ads
  70.  
  71. var ads = document.querySelectorAll('.b_ad, .b_adBottom');
  72. ads = Array.prototype.slice.apply(ads);
  73. ads.map(function (ad) {
  74. ad.remove();
  75. });
  76. }) (this, this.document);