Greasy Fork

Greasy Fork is available in English.

Ebay Buy It Now by Price

Auto set Buy It Now, sort by price and Gallery view parameters on Ebay search

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @run-at document-start
// @name        Ebay Buy It Now by Price
// @namespace   EBINbP
// @description Auto set Buy It Now, sort by price and Gallery view parameters on Ebay search
// @version     1.1
// @copyright   2015 steve
// @include     http://www.ebay.tld/sch/*
// @include     https://www.ebay.tld/sch/*
// @grant       none
// ==/UserScript==

try {
    var url = document.location.toString();
    var updateUrl = url

//    console.log(url);   // original URI
    updateUrl = updateQueryStringParameter(updateUrl, 'LH_Auction', ''); // remove Auction
    updateUrl = updateQueryStringParameter(updateUrl, 'LH_BIN', '1');   // Buy it NOW parameter
    updateUrl = updateQueryStringParameter(updateUrl, '_sop', '15');   // Sort by price parameter
    updateUrl = updateQueryStringParameter(updateUrl, '_dmd', '2');   // Gallery view parameter
//    console.log(updateUrl);   // changed URI
//    console.log(url != updateUrl);   // true = URI has changed

    if (url != updateUrl) {
        document.location = updateUrl;
    }
} catch (e) {}

// set, change or remove parameter
function updateQueryStringParameter(uri, key, value) {
    // remove parameter if empty value
    var parameterSet = (key.length && value.length > 0 ? key + "=" + value : "");
    var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
    var separator = uri.indexOf('?') !== -1 ? "&" : "?";
    if (uri.match(re)) {
        parameterSet = (parameterSet.length > 0 ? parameterSet +'$2' : "");
        return uri.replace(re, '$1' + parameterSet);
    } else {
        parameterSet = (parameterSet.length > 0 ? separator + parameterSet : "");
        return uri + parameterSet;
    }
}