Sort by first message button

Adds a "Sort by first message" button to the button group at the top of subforum pages

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Sort by first message button
// @namespace    incelerated
// @version      0.2
// @description  Adds a "Sort by first message" button to the button group at the top of subforum pages
// @author       incelerated
// @match        https://incels.is/forums/*
// @grant        none
// ==/UserScript==

$("document").ready(function(){

    var url = window.location.href;
	var forumName = url.split("/")[4];
	var buttonHTML = "";

    //if it's already sorted by first message make the button sort by last message
    if(url.indexOf("order=post_date&direction=desc") != -1){
        buttonHTML = `
			<a href="/forums/` + forumName + `/" class="button--link button"><span class="button-text">
			Sort by last message
			</span></a>
		`;
    }
	else{
		buttonHTML = `
			<a href="/forums/` + forumName + `/?order=post_date&direction=desc" class="button--link button"><span class="button-text">
			Sort by first message
			</span></a>
		`;
	}

	var btn = $(buttonHTML);
	$(".p-body-pageContent .block-outer .buttonGroup").prepend(btn);

});