Old Reddit Top Filters (1h,24h,W,M,Y,all)

Add quick filter buttons to tab menu.

// ==UserScript==
// @name        Old Reddit Top Filters (1h,24h,W,M,Y,all)
// @description Add quick filter buttons to tab menu.
// @version     1.0
// @author      C89sd
// @namespace   https://greasyfork.org/users/1376767
// @match       https://old.reddit.com/*
// @noframes
// ==/UserScript==

const tabMenu = document.querySelector('.tabmenu');
if (!tabMenu) return;

const { origin, pathname } = window.location;
const m = pathname.match(/^\/r\/[^/]+/);
const baseUrl = origin + (m ? m[0] : '');

const menuHTML =
'<li><a class="choice" href="' + baseUrl + '/top/?sort=top&t=hour">1h</a></li>' +
'<li><a class="choice" href="' + baseUrl + '/top/?sort=top&t=day">24h</a></li>' +
'<li><a class="choice" href="' + baseUrl + '/top/?sort=top&t=week">W</a></li>' +
'<li><a class="choice" href="' + baseUrl + '/top/?sort=top&t=month">M</a></li>' +
'<li><a class="choice" href="' + baseUrl + '/top/?sort=top&t=year">Y</a></li>' +
'<li><a class="choice" href="' + baseUrl + '/top/?sort=top&t=all">all</a></li>';

tabMenu.insertAdjacentHTML('beforeend', menuHTML);