TW-FriendsEvents

Add a button for filtering friends who wants event stuff

目前为 2014-07-19 提交的版本。查看 最新版本

// ==UserScript==
// @name        TW-FriendsEvents
// @description   Add a button for filtering friends who wants event stuff
// @include     http://*.the-west.*/game.php*
// @version     1.4.0
// @nocompat Chrome
// @grant       none
// @namespace https://gf.qytechs.cn/users/2196
// ==/UserScript==
(function(e) {
	var t = document.createElement("script");
	t.type = "application/javascript";
	t.textContent = "(" + e + ")();";
	document.body.appendChild(t);
	t.parentNode.removeChild(t);
})
		(function() {
			if (/http:\/\/.+\.the-west\..*\/game\.php.*/
					.test(window.location.href)) {

				FriendsEvents = {
					id : "",
					interval : 0,
					ready : false,
					create : function(runId) {

						try {

							this.id = runId;

							WestUi.FriendsBar.friendsBarUi.friendsBar.filterTypes_[runId
									.toLowerCase()] = function(player) {

								if (player.name === Character.name)
									return false; 

								var ev = Game.sesData[runId];

								var lastActivation = WestUi.FriendsBar.friendsBarUi.friendsBar
										.getEventActivation(runId,
												player.player_id);

								var diff = lastActivation
										+ parseInt(ev.friendsbar.cooldown, 10)
										- new ServerDate().getTime() / 1000;

								return (diff < 0);

							};

							var img = $('<img class="filter_event'
									+ runId
									+ '" src="/images/interface/friendsbar/events/'
									+ runId + '.png" />');

							var here = $('div.toggler-left');

							here.before($('<div class="fbar-event-img"  />')
									.append(img));
							img
									.click(function(e) {
										if (!isDefined(WestUi.FriendsBar.friendsBarUi.friendsBar.activeFilters_[runId
												.toLowerCase()])) {

											WestUi.FriendsBar.friendsBarUi
													.inLine(runId);

											$('.filter_event' + runId).css({
												'opacity' : '1'
											});
										} else {
											WestUi.FriendsBar.friendsBarUi.friendsBar
													.setFilter(runId
															.toLowerCase(),
															null);

											$('.filter_event' + runId).css({
												'opacity' : '0.43'
											});
											WestUi.FriendsBar.friendsBarUi
													.changeEvents_('listen');
										}
									}

									);
							img.css({
								'opacity' : '0.43',
								'cursor' : 'pointer'
							});

							this.ready = true;
						} catch (e) {
							ErrorLog.log('Erreur de creation du button : ', e);
						}
						return this;
					}

				};

				try {
 
					FriendsEvents.interval = setInterval(
							function() {

								var loading = false;
								if (Game.loaded
										&& isDefined(WestUi.FriendsBar.friendsBarUi)) {
									loading = true;

								}
								if (loading) {
									WestUi.FriendsBar.friendsBarUi.inLine = function(
											eventId) {

										WestUi.FriendsBar.friendsBarUi
												.changeEvents_('unlisten');
										$('.filter_event' + eventId).css({
											'opacity' : '1'
										});
										WestUi.FriendsBar.friendsBarUi.friendsBar
												.setFilter(eventId
														.toLowerCase(), true);

									};

									clearInterval(FriendsEvents.interval);
									var runningEvents = west.events.sesManager
											.getRunningEvents();
									// for each active events
									for (var i = 0; i < runningEvents.length; i++) {
										var runId = runningEvents[i].id;

										Game.sesData[runId].friendsEvent = FriendsEvents
												.create(runId);
									}

									FriendsEvents.ready = true;
								}

							}, 500);

				} catch (e) {
					ErrorLog.log("Erreur d'initialisation", e);

					FriendsEvents.ready = false;
				}

			}

		});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址