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

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/10 16:39:19
🔄 下次更新时间:2026/01/10 17:39:19
手动刷新缓存

Game Comments Enhancer *OLD*

Lets you specify a rating threshold for & adds pagination to comments

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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

公众号二维码

扫码关注【爱吃馍】

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

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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

公众号二维码

扫码关注【爱吃馍】

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

// ==UserScript==
// @name           Game Comments Enhancer *OLD*
// @namespace      ventero.de
// @author         Ventero
// @description    Lets you specify a rating threshold for & adds pagination to comments
// @include        http://www.kongregate.com/games/*/*
// @include        http://www.kongregate.com/games/*/*/comments*
// @date           26.09.2011
// @version        1.4
// require        http://kong.ventero.de/updates/84216.js
// @license        MIT license
// ==/UserScript==

// Written by Ventero (http://www.kongregate.com/accounts/Ventero) 08/23/2010
// Licensed under MIT/X11 license
// Copyright (c) 2010 Ventero
// http://www.opensource.org/licenses/mit-license.php

if(window != top) return;

function runInScope(src, args){
	var s = document.createElement("script");
	s.textContent = "" +
	"if(typeof CommentsEnhancer === 'undefined'){" +
	"	CommentsEnhancer = {}" +
	"};" +
	"(function(args){" +
		"(" + src.toString() + ").apply(CommentsEnhancer, args);" +
	"})(" + (args ? JSON.stringify(args) : "") + ");";
	document.body.appendChild(s);
	setTimeout(function(){document.body.removeChild(s);}, 100);
}

var OPTION = "kong_rating_threshold";
var threshold = GM_getValue(OPTION, "all");

GM_registerMenuCommand("Set comments rating threshold", function(){
	var r = prompt("Please enter the rating threshold. To show all comments, " +
	               "don't enter anything (or random text) and click ok")

	window.setTimeout(function(){
		GM_setValue(OPTION, r);
	}, 0);
	runInScope(function(t){
		this.threshold = this.parseThreshold(t);
		this.showComments();
	}, [r]);
});

runInScope(function(threshold){
function parseThreshold(value){
	var parsed = parseInt(value, 10);
	if(isNaN(parsed))
		return -Infinity;
	else
		return parsed;
}

function showComments(target){
	var threshold = CommentsEnhancer.threshold;
	if(target) {
		target = $(target);
	} else {
		target = $("comments_list") || $("all_comments");
	}

	function hide(a){
		target.down("#" + a).hide();
	}

	function show(a){
		target.down("#" + a).show();
	}

	function getRating(a){
		return parseInt(target.down("#comment_current_rating_" + a).innerHTML, 10);
	}

	var comments = target.getElementsByClassName("user_message comment"), current, id;
	for(var i = comments.length - 1; i >= 0; i--){
		current = comments[i];
		id = current.id.split("_")[1];

		if(getRating(id) > threshold) {
			current.className = current.className.replace("below_threshold", "above_threshold");
			hide('show_comment_content_' + id);
			show('hide_comment_content_' + id);
			show('comment_content_' + id);
		} else {
			current.className = current.className.replace("above_threshold", "below_threshold");
		  show('show_comment_content_' + id);
		  hide('hide_comment_content_' + id);
		  hide('comment_content_' + id);
		}
	}
}

var recent = $('recent_comments')
if(recent && !recent.down(".user_message.comment")) {
	recent.observe("DOMNodeInserted", function(){
		if(!recent.down(".user_message.comment")) return;
		recent.stopObserving("DOMNodeInserted");
		showComments(recent);
	});
}

this.threshold = parseThreshold(threshold);
this.parseThreshold = parseThreshold;
this.showComments = showComments;

showComments();
}, [threshold]);

/////////////////////////////////////////////////////////////////////////
if(!document.getElementById("comments_list")) return;

runInScope(function(){
var self = this;
var commentsUrl = location.pathname + "/comments";

function loadComments(event, target, params){
	divs[params.sort].down("div").hide();
	$("spinner_" + params.sort).show();

	var tempDiv = new Element("div");

	new Ajax.Updater({success: tempDiv}, commentsUrl, {
		method: "get",
		parameters: params,
		requestHeaders: { "Accept" : "text/html, */*" },
		onComplete: function(r){
			var commentsList = tempDiv.down("div#all_comments").down("div");
			var pagination = tempDiv.down(".pagination.simple_pagination");

			var oldPagination = target.down(".pagination.simple_pagination");
			if(oldPagination) oldPagination.remove();

			self.showComments(commentsList);
			target.down("div").update(commentsList.innerHTML);
			target.appendChild(pagination);

			var links = ["next", "last", "prev", "first"];

			links.forEach(function(type){
				var link = pagination.down("li." + type).down("a");
				if(link && link.href){
					var paramString = link.href.substring(link.href.indexOf("?"));
					if(!paramString) return;
					var newParams = paramString.toQueryParams();
					link.observe("click", function(event){
						return loadComments(event, target, newParams);
					});
					link.href = "#";
				}
			});

			$("spinner_" + params.sort).hide();
			divs[params.sort].down("div").show();
			resetLinks[params.sort].show();
			comments_controller._comment_ids = commentsList.select(".user_message.comment").map(function(ele){
				return ele.id.split("_")[1];
			});
			comments_controller.checkUserRatingStatus();
		}
		/* TODO: onFailure */
	});

	if(event.stop) event.stop();
	if(event.preventDefault) event.preventDefault();
	return false;
}

var fiveBest, fiveRecent, origIds;

function loadInitialBest(event){
	origIds = comments_controller._comment_ids;
	fiveBest = top.down("div").innerHTML;
	topMore.hide();

	return loadComments(event, top, {sort: "best"});
}

function loadInitialRecent(event){
	fiveRecent = recent.down("div").innerHTML;
	recentMore.hide();

	return loadComments(event, recent, {sort: "newest"});
}

function reset(event, target, orig, more, reset){
	target.down("div").update(orig);
	var pagination = target.down(".pagination.simple_pagination");
	if(pagination) pagination.remove();
	more.show();
	reset.hide();

	comments_controller._comment_ids = origIds;
	comments_controller.checkUserRatingStatus();

	if(event.stop) event.stop();
	if(event.preventDefault) event.preventDefault();

	return false;
}

function resetBest(event){
	return reset(event, top, fiveBest, topMore, topReset);
}

function resetRecent(event){
	return reset(event, recent, fiveRecent, recentMore, recentReset);
}

var list = $("comments_list");
var top = list.down(".top_comments");
var recent = $("recent_comments");
var divs = {best: top, newest: recent};

var topMore = new Element("a", {href: "#"}).update("(see more)");
var recentMore = new Element("a", {href: "#"}).update("(see more)");
var topReset = new Element("a", {href: "#"}).update("(see less)").hide();
var recentReset = new Element("a", {href: "#"}).update("(see less)").hide();
var resetLinks = {best: topReset, newest: recentReset}

top.down(".comments_type").insert(" ").insert(topMore).insert(topReset);
topMore.observe("click", loadInitialBest);
topReset.observe("click", resetBest);

recent.down(".comments_type").insert(" ").insert(recentMore).insert(recentReset);
recentMore.observe("click", loadInitialRecent);
recentReset.observe("click", resetRecent);

var topSpinner = new Element("span", {"class": "spinner spinner_big", "id": "spinner_best"}).update("loading").hide();
var recentSpinner = new Element("span", {"class": "spinner spinner_big", "id": "spinner_newest"}).update("loading").hide();

top.insert(topSpinner);
recent.insert(recentSpinner);
});