Greasy Fork

SteamCN Remember Last Search Mode

try to take over the world!

当前为 2018-04-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         SteamCN Remember Last Search Mode
// @namespace    maboroshi
// @version      0.2
// @description  try to take over the world!
// @author       maboroshi
// @match        *://steamcn.com
// @match        *://steamcn.com/*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==
(function () {
    'use strict';
    document.querySelector('a[data-mod="forum"]').addEventListener('click', () => GM_setValue('Steamcn_LastMode', 'forum'));
    document.querySelector('a[data-mod="user"]').addEventListener('click', () => GM_setValue('Steamcn_LastMode', 'user'));
    document.querySelector('a[data-mod="google"]').addEventListener('click', () => GM_setValue('Steamcn_LastMode', 'google'));
    document.querySelector('a[data-mod="baidu"]').addEventListener('click', () => GM_setValue('Steamcn_LastMode', 'baidu'));
    let ModeName;
    switch (GM_getValue('Steamcn_LastMode')) {
        case 'forum':
            ModeName = '帖子';
            break;
        case 'user':
            ModeName = '用户';
            break;
        case 'google':
            ModeName = 'Google';
            break;
        default:
            ModeName = '百度';
            break;
    }
    document.querySelector('.search-bar-form .dropdown .btn span:first-child').textContent = ModeName;
    document.querySelector('.search-bar-form input[name="mod"]').value = GM_getValue('Steamcn_LastMode', '百度');
})();