地址精简

去掉 抖音、bilibili、西瓜、腾讯新闻 网址的多余部分,减小长度。

目前为 2024-04-20 提交的版本。查看 最新版本

// ==UserScript==
// @name         地址精简
// @namespace    http://domain.com/directory
// @version      0.3.4
// @author       幸福的赢得
// @match        *.douyin.com/*
// @match        *.iesdouyin.com/*
// @match        *.bilibili.com/*
// @exclude      *//m.bilibili.com/search*
// @exclude      *//search.bilibili.com/*
// @exclude      *//www.bilibili.com/video/*
// @match        *.ixigua.com/*
// @match        *.inews.qq.com/*
// @include               /^https?:\/\/(greasy|sleazy)fork\.org\/[^/]+\/scripts\/\d+-/
// @grant        none
// @description 去掉 抖音、bilibili、西瓜、腾讯新闻 网址的多余部分,减小长度。
// ==/UserScript==

if (/\/\/greasyfork/.test (location.href) ) {
    const m =
    /(\/[^/]+\/scripts\/\d+)-[^/]+(\/.*)?/.exec(location.pathname)
    history.replaceState({}, null, `${location.origin}${m[1]}${m[2] ?? ''}${location.search}${location.hash}`)
}


if (/\?/.test (location.href) ) {
    var plainPath =
    location.href.replace (/\?.*/, "")
    history.pushState({}, '', plainPath);
}