🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2025/12/26 02:36:48
🔄 下次更新时间:2025/12/26 03:36:48
手动刷新缓存

Sort Flags

Allows you to sort flags by on your user flag page

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name           Sort Flags
// @author         AstroCB
// @description    Allows you to sort flags by on your user flag page
// @version        1.0
// @namespace  https://github.com/AstroCB
// @include        *://*.stackexchange.com/users/flag-summary/*
// @include        *://*stackoverflow.com/users/flag-summary/*
// @include        *://*serverfault.com/users/flag-summary/*
// @include        *://*superuser.com/users/flag-summary/*
// @include        *://*askubuntu.com/users/flag-summary/*
// @include        *://*stackapps.com/users/flag-summary/*
// ==/UserScript==

function showFlagType(type) {
	var pn = parseInt($(".pager.fr > a:nth-last-child(2)").attr("href").replace("?page=", ""));
	$("#mainbar").text("");
	for (var i = 1; i < pn + 2; i++) {
		$("#mainbar").append('<div id="mainbar' + i + '"></div>');
		if (type === "All") {
			$("#mainbar" + i).load(location.href + "?page=" + i + " #mainbar", function () {
				$(".pager.fr").remove()
			});
		} else {
			$("#mainbar" + i).load(location.href + "?page=" + i + " #mainbar > .flagged-post:has(span." + type + ")", function () {
				$(".pager.fr").remove()
			});
		}
	}
}

function showDeclined() {
	showFlagType("Declined");

	// Update button text and hide other buttons
	$("#flag-sort-declined").text("declined");
	hide(["disputed", "helpful", "all"]);
}

function showDisputed() {
	showFlagType("Disputed");

	// Update button text and hide other buttons
	$("#flag-sort-disputed").text("disputed");
	hide(["declined", "helpful", "all"]);
}

function showHelpful() {
	showFlagType("Helpful");

	// Update button text and hide other buttons
	$("#flag-sort-helpful").text("helpful");
	hide(["declined", "disputed", "all"]);
}

function showAll() {
	showFlagType("All");

	// Update button text and hide other buttons
	$("#flag-sort-all").text("all");
	hide(["declined", "disputed", "helpful"]);
}

function hide(buttons) { // Hide other buttons when one is clicked
	for (var i = 0; i < buttons.length; i++) {
		$("#flag-sort-" + buttons[i]).hide();
	}
}

function main() {
	// Button styling
	var style = document.createElement("style");
	style.type = "text/css";
	style.innerText = ".flag-sort { margin-left: 25px; cursor: pointer; }";
	document.getElementsByTagName("head")[0].appendChild(style);

	// Declined
	var declined = document.createElement("span");
	declined.innerText = "show declined";
	declined.setAttribute("id", "flag-sort-declined");
	declined.setAttribute("class", "flag-sort mod-flag-indicator");
	declined.style.backgroundColor = "#f00" // Spam red
	declined.onclick = showDeclined;

	// Disputed
	var disputed = document.createElement("span");
	disputed.innerText = "show disputed";
	disputed.setAttribute("id", "flag-sort-disputed");
	disputed.setAttribute("class", "flag-sort mod-flag-indicator");
	disputed.style.backgroundColor = "#f90" // Supernova orange
	disputed.onclick = showDisputed;

	// Helpful
	var helpful = document.createElement("span");
	helpful.innerText = "show helpful";
	helpful.setAttribute("id", "flag-sort-helpful");
	helpful.setAttribute("class", "flag-sort mod-flag-indicator");
	helpful.style.backgroundColor = "#33a030" // Rep green
	helpful.onclick = showHelpful;

	// All
	var all = document.createElement("span");
	all.innerText = "show all";
	all.setAttribute("id", "flag-sort-all");
	all.setAttribute("class", "flag-sort mod-flag-indicator");
	all.style.backgroundColor = "#07d" // Bounty blue
	all.onclick = showAll;

	// Container to be appended for the buttons
	var container = document.createElement("div");
	container.style.display = "inline-block";
	container.appendChild(declined);
	container.appendChild(disputed);
	container.appendChild(helpful);
	container.appendChild(all);

	document.getElementsByClassName("subheader")[0].children[0].appendChild(container);
}

// Inject helper functions
var functions = showFlagType.toString() + "\n\n" + showDeclined.toString() + "\n\n" + showDisputed.toString() + "\n\n" + showHelpful.toString() + "\n\n" + showAll.toString() + "\n\n" + hide.toString();
var functionScript = document.createElement('script');
functionScript.type = "text/javascript";
functionScript.textContent = functions;
document.body.appendChild(functionScript);

// Inject the main script
var script = document.createElement('script');
script.type = "text/javascript";
script.textContent = "(" + main.toString() + ")();";
document.body.appendChild(script);