Clean URL Query

Trim tracking query params from URL

10.10.2018 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Clean URL Query
// @namespace    http://leesei.github.io
// @version      1.0
// @description  Trim tracking query params from URL
// @author       [email protected]
// @supportURL   https://github.com/leesei/userscripts
// @match        http*://detail.tmall.com/item.htm*
// @match        http*://item.taobao.com/item.htm*
// @run-at       document-start
// @grant        GM_log
// @grant        GM_info
// @noframes
// ==/UserScript==

function log(level, text) {
    GM_log(level + ": " + text);
}

function query2json(querystring) {
    // remove any preceding url and split
    var queries = querystring.substring(querystring.indexOf('?')+1).split('&');
    var params = {}, pair, d = decodeURIComponent;
    // march and parse
    for (var i = queries.length - 1; i >= 0; i--) {
        pair = queries[i].split('=');
        params[d(pair[0])] = d(pair[1]);
    }

    return params;
}

(function() {
    'use strict';

    log('info', '>>> [' + GM_info.script.namespace + '] Trim URL Query <<<')

    var queries = query2json(location.search)
    // log('info', JSON.stringify(queries))
    log('info', Object.keys(queries))
    if (Object.keys(queries).length > 1) {
        location.replace(location.pathname + '?id=' + queries.id)
    }
})();