Google Bangs

Easily add DuckDuckGo bangs to Google.

目前為 2015-08-14 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Google Bangs
// @namespace   Google Bangs
// @description Easily add DuckDuckGo bangs to Google.
// @include     *://*.google.com/search*
// @version     1.2
// @compatible  firefox
// @grant       none
// ==/UserScript==

console.log('Initializing Google Bangs.');

var bangs=[],search=document.getElementById('lst-ib').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('rt','http://rottentomatoes.com','http://www.rottentomatoes.com/m/','_');
new Bang('rts','http://rottentomatoes.com','http://www.rottentomatoes.com/search/?search=','+');
new Bang('mc','http://minecraft.gamepedia.com/Minecraft_Wiki','http://minecraft.gamepedia.com/index.php?search=','+');
new Bang('sc','https://soundcloud.com','https://soundcloud.com/search?q=','%20');
new Bang('wot','https://mywot.com','https://www.mywot.com/scorecard/','');
new Bang('gm','https://mail.google.com','https://mail.google.com/mail/u/#search/','+');
new Bang('isup','http://isup.me','http://isup.me/','');
new Bang('gh','https://github.com','https://github.com/search?q=','+');
new Bang('gf','https://greasyfork.org/scripts','https://greasyfork.org/scripts/search?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){
      console.log('Search.');
      location.assign(bang.urlSearch+search.substr(bang.bang.length+1).replace(new RegExp(' ','g'),bang.spaceReplace));
    }else{
      console.log('Not a search.');
      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);
}