Better Bing

A better Bing experience

2015-09-24 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Better Bing
// @namespace   feifeihang.info
// @description A better Bing experience
// @include     *.bing.com/search*
// @version     1
// @grant       none
// ==/UserScript==
(function (window, document, undefined) {
  var COLORS = [
    '#FFFF00',
    '#CCCCFF',
    '#00CCFF',
    '#33CCCC',
    '#FF8080',
    '#FFCC00',
    '#008000',
    '#FFFF99',
    '#808000',
    '#FFFFCC'
  ];
  //   find all <strong> for highlighting
  var strongs = document.querySelectorAll('strong');
  var count = 0;
  var style = {
  };
  strongs = Array.prototype.slice.apply(strongs);
  strongs.map(function (strong) {
    var item = strong.textContent;
    if (style[item]) {
      strong.style.background = style[item];
      strong.style.color = '#000';
      strong.style.fontWeight = 'bold';
    } 
    else {
      style[item] = COLORS[count++];
      if (count >= COLORS.length) {
        count = 0;
      }
      strong.style.background = style[item];
      strong.style.color = '#000';
      strong.style.fontWeight = 'bold';
    }
  });
  //   add top button.
  var btn = document.createElement('div');
  btn.id = 'better-bing-top-btn';
  btn.style = 'display: none; border-radius: 100%; position: fixed; bottom: 20px; right: 20px;' +
  'height: 50px; width: 50px; line-height: 50px; color: #fff; background: #CC0000;' +
  'cursor: pointer; text-align: center; text-weight: bold; box-shadow: 0 2px 5px grey;';
  btn.textContent = 'TOP';
  btn.onclick = function () {
    window.scrollTo(0, 0);
  };
  document.body.appendChild(btn);
  window.addEventListener('scroll', function () {
    if (window.pageYOffset >= 30) {
      document.querySelector('#better-bing-top-btn').style.display = 'block';
    } 
    else {
      document.querySelector('#better-bing-top-btn').style.display = 'none';
    }
  });
  //   remove annoying right context contents.
  var context = document.querySelector('#b_context');
  if (context) {
    context.remove();
  }
  //   remove ads

  var ads = document.querySelectorAll('.b_ad, .b_adBottom');
  ads = Array.prototype.slice.apply(ads);
  ads.map(function (ad) {
    ad.remove();
  });
}) (this, this.document);