Bing Bangs

Easily add DuckDuckGo bangs to Bing.

目前為 2018-04-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Bing Bangs
// @namespace   Bing Bangs
// @description Easily add DuckDuckGo bangs to Bing.
// @include     *.bing.com/search*
// @version     1.1
// @grant       none
// ==/UserScript==

var bangs=[],search=document.getElementById('sb_form_q').value;

//BANGS
new Bang('yt','https://youtube.com/feed/subscriptions','https://www.youtube.com/results?search_query=','+');
new Bang('ddg','https://duckduckgo.com','https://duckduckgo.com/?q=','+');
new Bang('so','https://stackoverflow.com','http://stackoverflow.com/search?q=','+');
new Bang('imdb','http://imdb.com','http://www.imdb.com/find?s=all&q=','+');
new Bang('gh','https://github.com','https://github.com/search?q=','+');
new Bang('gf','https://greasyfork.org/scripts','https://greasyfork.org/scripts/search?q=','+');
new Bang('gg','https://google.com','https://www.google.com/search?q=','+');
new Bang('zh','https://www.zhihu.com/topic','https://www.zhihu.com/search?q=','+');
new Bang('tb','https://taobao.com','https://s.taobao.com/search?q=','+');
new Bang('db','https://douban.com','https://www.douban.com/search?q=','+');
new Bang('bd','https://baidu.com','https://www.baidu.com/s?wd=','%20');
new Bang('bl','https://bilibili.com','https://search.bilibili.com/all?keyword=','%20');
new Bang('pc','https://www.pin-cong.com/local/search/page/','https://www.pin-cong.com/local/search/page/?q=','+');
//BANGS

for(var i in bangs){
  var bang=bangs[i];
  if(search.substr(0,bang.bang.substr(1).length+1)==bang.bang){
    if(bang.urlSearch&&search.indexOf(' ')>=0)location.assign(bang.urlSearch+search.substr(bang.bang.length+1).replace(new RegExp(' ','g'),bang.spaceReplace));
    else location.assign(bang.urlEmpty);
  }
}

function Bang(bang,urlEmpty,urlSearch,spaceReplace){
  this.bang='!'+bang;
  this.urlEmpty=urlEmpty;
  this.urlSearch=urlSearch;
  this.spaceReplace=spaceReplace;
  bangs.push(this);
  this.bang='!'+bang;
  bangs.push(this);
}