Overview Redirect

Change all username urls to point to overviews instead of profiles

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Overview Redirect
// @name:en      Overview Redirect
// @version      4.1
// @description  Change all username urls to point to overviews instead of profiles
// @namespace    Overview Redirect
// @author       https://github.com/kimpeek
// @include      https://www.reddit.com*
// ==/UserScript==

// Define the regex for a username link
var username_link = new RegExp("(\/u\/|\/user\/)[A-Za-z0-9_-]+\/?$");
// Choose the page to replace with
//   Must be valid www.reddit.com/user/<USER>/*
//   eg. 'overview' or 'submitted'
var page_to_link = "overview";

// Find all links that point to a username
// and add 'page_to_link' to the end
function find_username_links(item, index){
    if (item.href.match(username_link)){
        item.href = change_username_link(item.href);
    }
}

// Conditionally add 'page_to_link' to the link
function change_username_link(link){
    if (link.endsWith("/")){
        link = link + page_to_link;
    }
    else {
        link = link + "/" + page_to_link;
    }
    return link;
}

// Wrapper for main functionality
function take_action(msg){
    // Gather all the links on the page
    var anchors = document.getElementsByTagName("a");
    // Transform the HTML Collection to an array
    var list = Array.from(anchors);
    // Execute the primary functionality
    list.forEach(find_username_links);
}

// Normal reddit and RES first page
window.addEventListener ("load", take_action());
// Never Ending Reddit
window.addEventListener ("neverEndingLoad", function(){take_action();});