Google Search Filter By Language Separately

Google Search's language filter is painful to use for multi-language users. It only support filtering between All language, Your primary language, and all languages you know. So as an chinese user who also know english, google can only show english and chinese results together, I can not filter English content only.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name Google Search Filter By Language Separately
// @description Google Search's language filter is painful to use for multi-language users. It only support filtering between All language, Your primary language, and all languages you know. So as an chinese user who also know english, google can only show english and chinese results together, I can not filter English content only.
// @version 201903112
// @include https://www.google.com/*
// @grant none
// @namespace https://greasyfork.org/users/165728
// ==/UserScript==

(function() {
    function addNewLangFilters() {
        const langList = [
            ['lang_zh-CN', '中文 (简体)'],
            ['lang_ja', '日本語'],
            ['lang_en', 'English'],
        ]
        langList.reverse() 
        let langItems = document.querySelectorAll("ul.hdtbU")[0].querySelectorAll(".hdtbItm")
        let primaryLang = langItems[1]
        let search_qs = primaryLang.querySelector('a').href

        for (const [code, name] of langList) {
            let newLang = primaryLang.cloneNode(true)
            let newLink = newLang.querySelector('a')
            newLink.innerHTML = name
            let url = new URL(newLink.href)
            let qs = new URLSearchParams(url.search);
            qs.set('lr', code)
            url.search = qs.toString()
            newLink.href = url.href
            primaryLang.after(newLang)
        }
    }
    function enableSearchTools() {
        document.getElementById('hdtb-tls').click()
    }

    setTimeout(addNewLangFilters, 1000*3)
})();