reddit legacy search feature

Add the ?feature=legacy_search flag to reddit searches

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         reddit legacy search feature
// @namespace    http://andytuba.com/
// @version      0.5
// @description  Add the ?feature=legacy_search flag to reddit searches
// @author       andytuba
// @match        *://*.reddit.com/*
// @grant        none
// ==/UserScript==

var form = document.querySelector('form#search');
var option = document.createElement('input');
option.type = 'hidden';
option.name = 'feature';
option.value = 'legacy_search';

form.appendChild(option);


var searchRegex = /^https?:\/\/(?:[\-\w\.]+\.)?reddit\.com\/(?:[\-\w\.\/]*\/)?search/i;
if (searchRegex.test(document.location) && document.location.search && document.location.search.indexOf('feature=legacy_search') === -1) {
    document.location = document.location.protocol + '//' + document.location.hostname + '/' + document.location.pathname + (document.location.search ? document.location.search + '&' : '?') + 'feature=legacy_search';
}