Greasy Fork

Greasy Fork is available in English.

ghoulHungerPercentages

Rulesy's ghoulHungerPercentages

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/31204/204646/ghoulHungerPercentages.js

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

var modules = modules || {};

modules.ghoulHungerPercentages = {

	name: 'Ghoul Hunger Percentages',

	description: 'Shows the percentage of your hunger bar.',

	icon: '/gfx/icons/small_ghoul.gif',

	pages: '.',

	init: function() {

		var ghoulBox = $('#ghoulHunger');

		if (ghoulBox.length == 0) {
			return;
		}

		var hungerContent = $('.content', ghoulBox);
		if (!hungerContent || !hungerContent.html()) {
			return;
		}

		if (hungerContent.html().match(/\%/)) {
			return;
		}

		var hungerBarWidth = 150; // pixels
		var hungerLimit = 40; // percent
		var hungerWidth = parseInt($('.hbar', ghoulBox).width());
		var percentageOfBar = 100 / hungerBarWidth * hungerWidth;
		var percentageOfHunger = 100 / hungerLimit * percentageOfBar;
		var newText = "Hunger : " + Math.round(percentageOfBar) + "% (" + Math.round(percentageOfHunger) + "% of limit)";

		var currentContent = hungerContent.html();

		hungerContent.html(currentContent.replace('Hunger :', newText));

		ghoulBox.domChange(function() {
			window.setTimeout(modules.ghoulHungerPercentages.init, 1000);
		});

	},

	config: function() {

		var content = '';

		content += '<h2>Before</h2>';
		content += '<img alt="before" src="http://die2nite.gamerz.org.uk/gm/images/mod_ghoulHungerPercentages_before.png">';
		content += '<h2>After</h2>';
		content += '<img alt="after" src="http://die2nite.gamerz.org.uk/gm/images/mod_ghoulHungerPercentages_after.png">';

		return content;
	}
}