Google Reader Search Current Feed Button

Add a new button next search button, to search current feed.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Google Reader Search Current Feed Button
// @namespace      http://qixinglu.com
// @description    Add a new button next search button, to search current feed.
// @include        http://www.google.com/reader/view/*
// @include        https://www.google.com/reader/view/*
// @version 0.0.1.20140517140356
// ==/UserScript==

var search_current_feed = function() {
    var url, search_string, replace_string, reg;
    url = window.location.href;
    search_string = document.getElementById("search-input").value;
    if (search_string === "") {
        return;
    }
    replace_string = "#search/" + search_string + "/";
    if (url.indexOf("#stream") !== -1) {
        window.location.href = url.replace("#stream",replace_string);
    } else if (url.indexOf("#search") != -1) {
        reg = new RegExp("#search/[^/]\+/");
        window.location.href = url.replace(reg,replace_string);
    }
}

var search_button = document.getElementById("gbqfb")
var new_search_button = search_button.cloneNode(true);
new_search_button.id = "gbqfb_new";
new_search_button.style.marginLeft = '8px';

new_search_button.addEventListener("click", search_current_feed, false);
new_search_button.addEventListener("mouseover", function() {
    this.classList.add('jfk-button-hover');
}, false);
new_search_button.addEventListener("mouseout", function() {
    this.classList.remove('jfk-button-hover');
}, false);

search_button.parentNode.appendChild(new_search_button);