Last active
February 14, 2020 18:14
-
-
Save kosorin/5718b97b0802566e53ce221d88559498 to your computer and use it in GitHub Desktop.
Temnota.cz UserScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Temnota Plus | |
// @namespace http://temnota.cz | |
// @include http://temnota.cz/* | |
// @include http://www.temnota.cz/* | |
// @version 7.1.1 | |
// @grant none | |
// @require https://code.jquery.com/jquery-3.2.1.min.js | |
// @require https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
console.clear(); | |
var kosorinRoot = 'http://www.kosorin.net/temnota/'; | |
function Settings() { | |
this.args = {}; | |
this.attributes = Cookies.getJSON('+attributes') || {}; | |
this.spells = Cookies.getJSON('+spells') || {}; | |
if (location.search) { | |
var argsData = location.search.substring(1).split('&'); | |
for (var i = 0; i < argsData.length; i++) { | |
[argKey, argValue] = argsData[i].split('='); | |
this.args[argKey] = argValue; | |
} | |
} | |
} | |
Settings.prototype.save = function () { | |
var options = { expires: 365 }; | |
Cookies.set('+attributes', this.attributes, options); | |
Cookies.set('+spells', this.spells, options); | |
}; | |
function Data() { | |
this.creatures = [ | |
{ | |
"image": "/img/creatures/fire.gif", | |
"name": "Ohnivý přízrak", | |
"hp": "60", | |
"attacks": "kouzlo" | |
}, | |
{ | |
"image": "/img/creatures/ice.gif", | |
"name": "Ledový přízrak", | |
"hp": "60", | |
"attacks": "kouzlo" | |
}, | |
{ | |
"image": "/img/creatures/rock.gif", | |
"name": "Kamenný přízrak", | |
"hp": "80", | |
"attacks": "zbraň" | |
}, | |
{ | |
"image": "/img/creatures/wind.gif", | |
"name": "Větrný přízrak", | |
"hp": "40", | |
"attacks": "paralýza" | |
}, | |
{ | |
"image": "/img/creatures/tree.gif", | |
"name": "Strom", | |
"hp": "80", | |
"attacks": "zbraň" | |
}, | |
{ | |
"image": "/img/creatures/eye_1.gif", | |
"name": "Zuřivé oko", | |
"hp": "35", | |
"attacks": "zbraň, kouzlo" | |
}, | |
{ | |
"image": "/img/creatures/eye_2.gif", | |
"name": "Krvavé oko", | |
"hp": "50", | |
"attacks": "zbraň, kouzlo" | |
}, | |
{ | |
"image": "/img/creatures/slime_1.gif", | |
"name": "Zelený sliz", | |
"hp": "20", | |
"attacks": "zbraň" | |
}, | |
{ | |
"image": "/img/creatures/slime_2.gif", | |
"name": "Červený sliz", | |
"hp": "30", | |
"attacks": "zbraň" | |
}, | |
{ | |
"image": "/img/creatures/ant.gif", | |
"name": "Obří mravenec", | |
"hp": "15", | |
"attacks": "Zbraň" | |
}, | |
{ | |
"image": "/img/creatures/spider_1.gif", | |
"name": "Velký pavouk", | |
"hp": "30", | |
"attacks": "zbraň" | |
}, | |
{ | |
"image": "/img/creatures/spider_2.gif", | |
"name": "Obří pavouk", | |
"hp": "40", | |
"attacks": "zbraň" | |
}, | |
{ | |
"image": "/img/creatures/medusa.gif", | |
"name": "Medúza", | |
"hp": "50", | |
"attacks": "zbraň, paralýza" | |
} | |
]; | |
this.usableItems = [ | |
'Mapa', | |
'Runový kámen', | |
'Svitek .*', | |
'Elixír (zdraví|rychlosti)', | |
'Měšec' | |
]; | |
this.spells = { | |
1: { | |
"id": 1, | |
"name": "První pomoc", | |
"icon": "❤️" | |
}, | |
2: { | |
"id": 2, | |
"name": "Uzdravení", | |
"icon": "❤️" | |
}, | |
3: { | |
"id": 3, | |
"name": "Život", | |
"icon": "❤️" | |
}, | |
4: { | |
"id": 4, | |
"name": "Ohnivá střela", | |
"icon": "🔥" | |
}, | |
5: { | |
"id": 5, | |
"name": "Ohnivá koule", | |
"icon": "🔥" | |
}, | |
6: { | |
"id": 6, | |
"name": "Ledová střela", | |
"icon": "❄️" | |
}, | |
7: { | |
"id": 7, | |
"name": "Ledová koule", | |
"icon": "❄️" | |
}, | |
8: { | |
"id": 8, | |
"name": "Blesk", | |
"icon": "⚡" | |
}, | |
9: { | |
"id": 9, | |
"name": "Paralýza", | |
"icon": "🖤" | |
}, | |
10: { | |
"id": 10, | |
"name": "Dračí dech", | |
"icon": "🐲" | |
} | |
}; | |
} | |
Data.prototype.searchSpellByName = function (name) { | |
for (var id in this.spells) { | |
var spell = this.spells[id]; | |
if (name.trim() == spell.name) { | |
return spell; | |
} | |
} | |
return { | |
"name": name, | |
"icon": "❓" | |
}; | |
}; | |
function Notification() { | |
this.audio = null; | |
} | |
Notification.prototype.play = function () { | |
if (this.audio == null) { | |
this.audio = new Audio(kosorinRoot + 'snd/notification.mp3'); | |
} | |
this.audio.play(); | |
}; | |
function ToolTip() { | |
var element = document.createElement("div"); | |
element.className = 'plus_tooltip'; | |
element.innerHTML = ''; | |
$(element).mouseleave(function () { | |
element.style.display = 'none'; | |
element.innerHTML = ''; | |
}); | |
$('body').append(element); | |
this.element = element; | |
} | |
ToolTip.prototype.clear = function () { | |
this.element.innerHTML = ''; | |
}; | |
ToolTip.prototype.append = function (content) { | |
this.element.innerHTML += content; | |
}; | |
ToolTip.prototype.show = function (target, content, positioner) { | |
if (content) { | |
this.element.innerHTML = content; | |
} | |
if (!this.element.innerHTML) { | |
return; | |
} | |
var rect = target.getBoundingClientRect(); | |
if (!positioner) { | |
this.element.style.left = rect.left + 'px'; | |
this.element.style.top = rect.bottom + 'px'; | |
} | |
else { | |
var position = positioner(rect); | |
this.element.style.left = position.x + 'px'; | |
this.element.style.top = position.y + 'px'; | |
} | |
this.element.style.display = 'block'; | |
}; | |
ToolTip.prototype.hide = function () { | |
this.element.style.display = 'none'; | |
this.element.innerHTML = ''; | |
}; | |
function PageScript() { | |
var settings = new Settings(); | |
var data = new Data(); | |
var toolTip = new ToolTip(); | |
$('.banner').remove(); | |
$('.leftbanner').remove(); | |
// Odstranění tlačítka pro spuštění hry na úvodní stránce (přesunuto do menu) | |
var runGameButton = $('#rungame'); | |
if (runGameButton.length) { | |
runGameButton.siblings('br').remove(); | |
runGameButton.remove(); | |
} | |
// Odstranění prodlevy mezi příspěvky | |
var forumBanElement = $('.cannotwrite'); | |
if (forumBanElement.length) { | |
var topicId = settings.args.top; | |
if (topicId) { | |
var form = document.createElement('form'); | |
form.action = 'forum-in.php?top=' + topicId; | |
form.method = 'post'; | |
form.innerHTML = '<input type="image" src="/img/desk/forum/write.gif" width=50" height="54" class="frbtn" /><textarea name="txt"></textarea>'; | |
$(form).insertAfter('.tit'); | |
} | |
forumBanElement.remove(); | |
} | |
// Zobrazení jmen v tabulce hrdinů | |
var onlineHeroContainer = $('#onlines'); | |
if (onlineHeroContainer.length) { | |
var table = document.createElement('table'); | |
table.className = 'top'; | |
onlineHeroContainer.removeAttr('id'); | |
onlineHeroContainer.append(table); | |
onlineHeroContainer.find('img').each(function () { | |
$(this).remove(); | |
var image = document.createElement('td'); | |
image.className = 'ico'; | |
image.appendChild(this); | |
var name = document.createElement('td'); | |
name.className = 'hername'; | |
name.innerHTML = this.title; | |
var row = document.createElement('tr'); | |
row.appendChild(image); | |
row.appendChild(name); | |
table.appendChild(row); | |
}); | |
} | |
// Úprava levého menu | |
var mainMenu = $('#mainmenu'); | |
var homeMenuItem = mainMenu.find('a')[0]; | |
var heroesMenuItem = mainMenu.find('a')[2]; | |
var imagesMenuItem = mainMenu.find('a')[3]; | |
homeMenuItem.innerHTML = 'aktuální dění'; | |
heroesMenuItem.innerHTML = 'hrdinové'; | |
imagesMenuItem.innerHTML = 'obrázky'; | |
var runGameMenuItem = document.createElement('a'); | |
runGameMenuItem.href = '/game'; | |
runGameMenuItem.className = 'mainmenuitem'; | |
runGameMenuItem.style = 'color: maroon'; | |
runGameMenuItem.innerHTML = 'spustit hru'; | |
$(runGameMenuItem).insertBefore(homeMenuItem); | |
settings.save(); | |
}; | |
function GameScript() { | |
var settings = new Settings(); | |
var data = new Data(); | |
var notification = new Notification(); | |
var toolTip = new ToolTip(); | |
var view = { | |
character: $('.menuitem-a[href="set.php?pgr_char=1"]').length > 0, | |
inventory: $('.menuitem-a[href="set.php?pgr_inv=1"]').length > 0, | |
spells: $('.menuitem-a[href="set.php?pgr_spel=1"]').length > 0, | |
chat: $('.menuitem-a[href="set.php?pgr_com=1"]').length > 0, | |
map: $('#left-block > #map').length > 0, | |
worldMap: $('#left-block > .worldmap').length > 0, | |
} | |
$('.banner').remove(); | |
/* ************************************************************************** */ | |
if (view.character) { | |
// Atributy | |
var attributes = $($('.stats')[0]); | |
if (attributes.length && attributes.find('[href*="addskill="]').length == 0) { | |
attributes.find('.mainstat > img').each(function () { | |
$(this).attr('title', $(this).attr('alt')); | |
}); | |
// Síla | |
var str = attributes.find('img')[0]; | |
var strValue = str.alt.replace('%', ''); | |
var strLabel = document.createElement('span'); | |
strLabel.className = 'plus_attribute'; | |
strLabel.innerHTML = strValue + '<span class="plus_attribute_small"> %</span>'; | |
$(str).parent().prepend(strLabel); | |
// Inteligence | |
var int = attributes.find('img')[1]; | |
var intValue = int.alt.replace('%', ''); | |
var intLabel = document.createElement('span'); | |
intLabel.className = 'plus_attribute'; | |
intLabel.innerHTML = intValue + '<span class="plus_attribute_small"> %</span>'; | |
$(int).parent().prepend(intLabel); | |
// Odolnost | |
var con = attributes.find('img')[2]; | |
var conValue = con.alt.replace('%', '') / 5; | |
var conLabel = document.createElement('span'); | |
conLabel.className = 'plus_attribute'; | |
conLabel.innerHTML = conValue + '<span class="plus_attribute_small"> BZ</span>'; | |
$(con).parent().prepend(conLabel); | |
// Výdrž | |
var sta = attributes.find('img')[3]; | |
var staValue = Math.min(99, sta.alt.replace('%', '') / 2); | |
var staLabel = document.createElement('span'); | |
staLabel.className = 'plus_attribute'; | |
staLabel.innerHTML = staValue + '<span class="plus_attribute_small"> AB</span>'; | |
$(sta).parent().prepend(staLabel); | |
settings.attributes.sta = staValue; | |
// Rychlost | |
var spd = attributes.find('img')[4]; | |
var spdValue = 420 - (1.8 * spd.alt.replace('%', '')); | |
var minute = Math.floor(spdValue / 60); | |
var second = spdValue % 60; | |
var spdLabel = document.createElement('span'); | |
spdLabel.className = 'plus_attribute'; | |
spdLabel.innerHTML = minute + '<span class="plus_attribute_small"> m</span>'; | |
if (second > 0) { spdLabel.innerHTML += second + '<span class="plus_attribute_small"> s</span>'; } | |
$(spd).parent().prepend(spdLabel); | |
settings.attributes.spd = spdValue; | |
// Štěstí | |
var lck = attributes.find('img')[5]; | |
var lckValue = lck.alt.replace('%', ''); | |
var lckLabel = document.createElement('span'); | |
lckLabel.className = 'plus_attribute'; | |
lckLabel.innerHTML = lckValue + '<span class="plus_attribute_small"> %</span>'; | |
$(lck).parent().prepend(lckLabel); | |
} | |
// Úroveň a zkušenosti | |
var experienceElement = $('.all-exp'); | |
if (experienceElement.length) { | |
var experience = experienceElement.attr('title').match(/^(\d+) \/ (\d+)$/); | |
var percent = Math.round((experience[1] / experience[2]) * 10000) / 100; | |
var missing = experience[2] - experience[1]; | |
var level = experience[2] / 500; | |
var label = experienceElement.parents().eq(2).find('th'); | |
label.css('overflow', 'visible'); | |
label.html('úroveň: <span style="font-weight: normal;">' + level + ' <span style="font-size: 10px;">(+' + percent + ' %)</span></span></span>'); | |
experienceElement.attr('title', experience[1] + ' / ' + experience[2] + ' (do další ' + missing + ' zk.)'); | |
} | |
// Úroveň zbraní | |
var weapons = $($('.stats')[1]); | |
if (weapons.length) { | |
weapons.find('div').each(function () { | |
var weapon = $(this); | |
var level = weapon.parent().find('img').attr('src').match(/\/lvl_(\d)\.gif$/)[1]; | |
var progress = weapon.attr('title').match(/^(\d+) \//)[1]; | |
weapon.attr('title', null); | |
if (level != 6 && (level != 0 || progress != 0)) { | |
var progressInfo = document.createElement('span'); | |
progressInfo.className = 'plus_weapon_level_info'; | |
progressInfo.innerHTML = progress; | |
var progressInfo100 = document.createElement('span'); | |
progressInfo100.className = 'plus_weapon_level_info_100'; | |
progressInfo100.innerHTML = '/100'; | |
weapon.append(progressInfo); | |
weapon.append(progressInfo100); | |
} | |
}); | |
} | |
} | |
/* ************************************************************************** */ | |
if (view.inventory) { | |
// Log | |
$('#msg-block > p > strong').each(function () { | |
var element = $(this.nextSibling); | |
var text = element.text().trim().match(/- (.*)/)[1]; | |
var newText = text; | |
element.remove(); | |
element = document.createElement('span'); | |
var color = 'black'; | |
var match; | |
if ((match = text.match(/^(.*) byl zasažen kouzlem (.*) (\((\+|-)(\d+) (AB|BZ)\))$/))) { | |
var spell = data.searchSpellByName(match[2]); | |
newText = '⚔️ ' + match[1] + ' ' + spell.icon + ' ' + match[2] + ' ' + match[3]; | |
} | |
else if ((match = text.match(/^(.*) byl zasažen, ale nezraněn.$/))) { | |
newText = '⚔️ ' + match[1] + ' 🗡️'; | |
} | |
else if ((match = text.match(/^(.*) byl paralizován.$/))) { | |
newText = '⚔️ ' + match[1] + ' ' + data.spells[9].icon + ' ' + data.spells[9].name; | |
} | |
else if ((match = text.match(/^(.*) byl paralizován. (\((\+|-)(\d+) (AB|BZ)\))$/))) { | |
newText = '⚔️ ' + match[1] + ' ' + data.spells[9].icon + ' ' + data.spells[9].name + ' ' + match[2]; | |
} | |
else if ((match = text.match(/^Zaútočil na mě (.*) a zranil mě. (\((\+|-)(\d+) (AB|BZ)\))$/))) { | |
newText = '🛡️ ' + match[1] + ' 🗡️ ' + match[2]; | |
color = 'red'; | |
} | |
else if ((match = text.match(/^(.*) na mě seslal kouzlo. (\((\+|-)(\d+) (AB|BZ)\))$/))) { | |
newText = '🛡️ ' + match[1] + ' ✨ ' + match[2]; | |
color = 'red'; | |
} | |
else if ((match = text.match(/^(.*) na mě seslal kouzlo (.*). (\((\+|-)(\d+) (AB|BZ)\))$/))) { | |
var spell = data.searchSpellByName(match[2]); | |
newText = '🛡️ ' + match[1] + ' ' + spell.icon + ' ' + match[2] + ' ' + match[3]; | |
color = 'red'; | |
} | |
else if ((match = text.match(/^Utočí na mě (.*), ale nezranil mě.$/))) { | |
newText = '🛡️ ' + match[1] + ' 🗡️'; | |
} | |
else if ((match = text.match(/^(.*) na mě seslal kouzlo, ale nezranil mě.$/))) { | |
newText = '🛡️ ' + match[1] + ' ✨'; | |
} | |
else if ((match = text.match(/^(.*) mě paralyzoval. (\((\+|-)(\d+) (AB|BZ)\))$/))) { | |
newText = '🛡️ ' + match[1] + ' 🖤 Paralýza ' + match[2]; | |
color = 'red'; | |
} | |
else if ((match = text.match(/^Vyléčil jsem se. \((\+\d+)BZ\)$/))) { | |
newText = '❤️ ' + match[1] + ' BZ'; | |
} | |
else if ((match = text.match(/^Vypil jsem elixír rychlosti. (\((\+|-)(\d+) (AB|BZ)\))$/))) { | |
newText = '🍺 Elixír rychlosti ' + match[1]; | |
} | |
else if ((match = text.match(/^Vypil jsem elixír zdraví. (\((\+|-)(\d+) (AB|BZ)\)).$/))) { | |
newText = '🍷 Elixír zdraví ' + match[1]; | |
} | |
else if ((match = text.match(/^(.* zemřel).$/))) { | |
newText = '💀 ' + match[1]; | |
} | |
else if ((match = text.match(/^(Zemřel jsem).$/))) { | |
newText = '💀 ' + match[1]; | |
} | |
else if ((match = text.match(/^(Zrodil jsem se|Povstal jsem z mrtvých).$/))) { | |
newText = '👶 ' + match[1]; | |
} | |
else if ((match = text.match(/^(Pohlcuje mě temnota).$/))) { | |
newText = '💩 ' + match[1]; | |
color = 'blue'; | |
} | |
else if ((match = text.match(/^(Naučil jsem se kouzlo .*).$/))) { | |
newText = '🎓 ' + match[1]; | |
} | |
else if ((match = text.match(/^((Koupeno|Prodáno): (.*) za (\d+) zlatých).$/))) { | |
newText = '💰 ' + match[1]; | |
} | |
element.innerHTML = ' - ' + newText; | |
$(this).after(element); | |
$(this).parent().css('color', color); | |
}); | |
// Předměty | |
$('.item').each(function () { | |
var item = $(this); | |
var id = item.attr('href').match(/[?&]iteminfo\=(\d+)$/)[1]; | |
var durability = item.parent().css('background').match(/32px -?(\d+)px/)[1] / 32; | |
// Zobrazení ceny předmětu + možnost rychlého zrušení | |
var priceTag = item.find('img[src*="/selling.gif"]'); | |
if (priceTag.length) { | |
var price = priceTag.attr('alt').match(/(\d+)/)[1]; | |
var priceInfo = document.createElement('div'); | |
priceInfo.className = 'plus_item_price_info'; | |
priceInfo.innerHTML = price; | |
var cancelSellingForm = document.createElement('form'); | |
cancelSellingForm.action = 'set.php'; | |
cancelSellingForm.method = 'post'; | |
cancelSellingForm.innerHTML += '<input type="hidden" name="item" value="' + id + '">'; | |
cancelSellingForm.innerHTML += '<input class="plus_item_cancel_selling_button" type="image" src="/img/desk/nosell.gif" name="nosell" width="16" height="16" class="sell-btn" />'; | |
item.before(priceInfo); | |
item.before(cancelSellingForm); | |
item.hover(function () { | |
$(priceInfo).hide(); | |
}, function () { | |
$(priceInfo).show(); | |
}); | |
priceTag.remove(); | |
} | |
}); | |
// Úprava různých tlačítek | |
var isSelectedItem = $('.iteminfo > .tit').length > 0; | |
var wearButton = $('.it-to-wear-button'); | |
var bagButton = $('.it-to-bag-button'); | |
var groundButton = $('.it-to-gound-button'); | |
if (!isSelectedItem) { | |
[wearButton, bagButton, groundButton].forEach(button => { | |
button.attr('href', null); | |
button.css('filter', 'grayscale(1)'); | |
}); | |
} | |
var showUseButton = false; | |
var useButton = $('.it-to-use-button'); | |
if (useButton.length) { | |
if (isSelectedItem) { | |
var itemTitle = $('.iteminfo > .tit'); | |
var namere = new RegExp(data.usableItems.map(function (i) { | |
return '(' + i + ')'; | |
}).join('|')); | |
if (namere.test(itemTitle.text())) { | |
showUseButton=true; | |
} | |
} | |
} | |
if (!showUseButton) { | |
useButton.remove(); | |
var mapButtonHtml = ''; | |
mapButtonHtml += '<form action="' + kosorinRoot + 'find.php" method="post" name="map_find_form" target="_blank" onsubmit="document.map_find_form.find.value = document.getElementById(\'map\').innerHTML; return true;">'; | |
mapButtonHtml += '<input id="map_find_button" type="image" class="button map_button" src="' + kosorinRoot + 'img/buttons/map.png" />'; | |
mapButtonHtml += '<input type="hidden" name="find" value="" />'; | |
mapButtonHtml += '</form>'; | |
bagButton.after(mapButtonHtml); | |
if (!view.map) { | |
$('#map_find_button').css('pointer-events', 'none'); | |
$('#map_find_button').css('filter', 'grayscale(1)'); | |
} | |
} | |
} | |
/* ************************************************************************** */ | |
if (view.spells) { | |
// Kouzla | |
var spellsContainer = $('.spells'); | |
if (spellsContainer.length) { | |
var learnedSpells = []; | |
spellsContainer.find('a[href*="?setspell="]').each(function () { | |
var spell = $(this); | |
var id = spell.attr('href').match(/[?&]setspell\=(\d+)$/)[1]; | |
learnedSpells.push(id); | |
var level = spell.siblings('.lvl').attr('src').match(/\/lvl_(\d)\.gif$/)[1]; | |
var progress = spell.siblings('.spell-exp').css('background').match(/0px -?(\d+(\.\d+)?)px/)[1]; | |
progress = Math.round(100 / (44 / progress)); | |
if (level != 6 && (level != 0 || progress != 0)) { | |
var progressInfo = document.createElement('div'); | |
progressInfo.className = 'plus_spell_level_info'; | |
progressInfo.innerHTML = progress; | |
var progressInfo100 = document.createElement('span'); | |
progressInfo100.className = 'plus_spell_level_info_100'; | |
progressInfo100.innerHTML = '/100'; | |
progressInfo.appendChild(progressInfo100); | |
spell.before(progressInfo); | |
spell.hover(function () { | |
$(progressInfo).hide(); | |
}, function () { | |
$(progressInfo).show(); | |
}); | |
} | |
}); | |
settings.spells = learnedSpells; | |
} | |
} | |
/* ************************************************************************** */ | |
if (view.map) { | |
// Tooltipy na předměty a příšery | |
$('#map').find('td > div').each(function () { | |
var field = $(this); | |
field.mouseenter(function () { | |
toolTip.clear(); | |
field.find('.hero').each(function () { | |
var hero = $(this); | |
var creature = null; | |
for (var i = data.creatures.length - 1; i >= 0; i--) { | |
if (hero.attr('src').indexOf(data.creatures[i].image) > -1) { | |
creature = data.creatures[i]; | |
break; | |
} | |
} | |
if (!creature) { | |
creature = {}; | |
creature.image = hero.attr('src'); | |
creature.name = hero.attr('alt'); | |
} | |
hero.attr('title', null); | |
toolTip.append('<table><tr><td><img src="' + creature.image + '" /></td><td valign="center"><span style="font-size: 16px; font-weight: bold;">' + creature.name + '</span></td></tr></table>'); | |
if (creature.hp) { toolTip.append('<p><b>Celkové zdraví:</b> ' + creature.hp + '</td></p>'); } | |
if (creature.attacks) { toolTip.append('<p><b>Útok:</b> ' + creature.attacks + '</td></p>'); } | |
toolTip.append('</table>'); | |
}); | |
field.find('.mapitem').each(function () { | |
var item = $(this); | |
toolTip.append('<img src="' + item.attr('src') + '" />'); | |
}); | |
toolTip.show(this); | |
}); | |
field.mouseleave(function () { | |
toolTip.hide(); | |
}); | |
}); | |
// Stopy | |
$('img[src*="/footstep/"]').each(function () { | |
var footstep = $(this); | |
var match = footstep.attr('src').match(/\/footstep\/(1|2|3|4)\.gif$/); | |
if (match) { | |
footstep.attr('src', kosorinRoot + 'img/footsteps/' + match[1] + '.png'); | |
footstep.attr('alt', null); | |
footstep.attr('title', null); | |
footstep.css('opacity', '0.6'); | |
} | |
}); | |
} | |
/* ************************************************************************** */ | |
if (view.worldMap) { | |
// Nahrazení obrázku hrdiny za šipku | |
var worldMap = $('.worldmap'); | |
if (worldMap.length) { | |
var positionImage = worldMap.find('img')[0]; | |
positionImage.src = 'https://b.zmtcdn.com/images/resprite_location/pin_res32.png'; | |
positionImage.width = '32'; | |
positionImage.height = '32'; | |
positionImage.style.position = 'relative'; | |
positionImage.style.top = '0px'; | |
positionImage.style.left = '0px'; | |
} | |
} | |
/* ************************************************************************** */ | |
if (view.character || view.inventory || view.spells) { | |
// Rychlý výběr kouzla | |
$('.as').contextmenu(function (e) { | |
e.preventDefault(); | |
var html = ''; | |
if (settings.spells && settings.spells.length > 0) { | |
for (var i = 0; i < settings.spells.length; i++) { | |
var id = Number(settings.spells[i]); | |
html += '<a href="/game/set.php?setspell=' + id + '" class="plus_spell_button"><img src="/img/spells/' + (0 + id) + '.gif" /></a>'; | |
} | |
} | |
else { | |
html += '<div style="margin: 8px"><b>Nenaučil ses ještě žádné kouzlo</b></div>'; | |
} | |
toolTip.show(this, html, function (rect) { | |
return { | |
x: rect.left, | |
y: rect.top | |
}; | |
}); | |
}); | |
// Aktualizace akčních bodů | |
var actionPointsElement = $('.actionpoins'); | |
if (actionPointsElement.length) { | |
var sta = settings.attributes.sta; | |
var spd = settings.attributes.spd; | |
if (sta && spd) { | |
var container = actionPointsElement.parent(); | |
var actionPoints = Number(actionPointsElement.text()); | |
var progress = Number(container.css('background').match(/\/(\d+)\.gif/)[1]); | |
var blinking = false; | |
var blink = function () { | |
if (blinking) { | |
return; | |
} | |
blinking = true; | |
actionPointsElement.css('transition', 'all 500ms ease-in-out'); | |
actionPointsElement.css('filter', 'contrast(1.2) hue-rotate(90deg)'); | |
setInterval(function () { | |
actionPointsElement.css('transform', 'scale(1.5)'); | |
setTimeout(function () { | |
actionPointsElement.css('transform', 'scale(1)'); | |
}, 500); | |
}, 1000); | |
}; | |
if (actionPoints == sta) { | |
blink(); | |
} | |
setInterval(function () { | |
progress = (progress == 0 ? 90 : progress - 10); | |
if (progress == 0) { | |
actionPoints += 1; | |
// if (actionPoints <= 5) { | |
// location.reload(); | |
// } | |
if (actionPoints > sta) { | |
actionPoints = sta; | |
blink(); | |
} | |
else { | |
actionPointsElement.css('transition', 'all 250ms ease-in-out'); | |
actionPointsElement.css('transform', 'scale(1.75)'); | |
actionPointsElement.css('color', 'red'); | |
setTimeout(function () { | |
actionPointsElement.css('transform', 'scale(1)'); | |
actionPointsElement.css('color', 'black'); | |
}, 250); | |
} | |
if (actionPoints >= sta - 5) { | |
notification.play(); | |
} | |
if (actionPoints <= 16) { | |
[ | |
['at', 'atack'], | |
['as', 'cast'] | |
].forEach(x => { | |
var element = $('.' + x[0]); | |
if (actionPoints >= element.text().trim()) { | |
element.parent().css('background', 'url(/img/desk/arrows/' + x[1] + '.gif)'); | |
} | |
}); | |
} | |
} | |
container.css('background', 'url(/img/desk/timer/' + progress + '.gif)'); | |
actionPointsElement.text(Math.floor(actionPoints)); | |
}, 1000 * (spd / 10)); | |
} | |
} | |
} | |
/* ************************************************************************** */ | |
// CSS | |
var css = document.createElement('style'); | |
css.innerHTML = ` | |
.plus_item_cancel_selling_button { | |
position: absolute; | |
margin: 22px 0px; | |
width: 10px; | |
height: 10px; | |
} | |
.plus_item_price_info, | |
.plus_spell_level_info { | |
pointer-events: none; | |
overflow: visible; | |
padding: 1px 0px; | |
font-size: 11px; | |
position: absolute; | |
text-align: center; | |
} | |
.plus_item_price_info { | |
border: 1px solid black; | |
background: yellow; | |
color: black; | |
width: 30px; | |
} | |
.plus_spell_level_info { | |
border: 1px solid black; | |
background: rgb(104, 33, 122); | |
color: white; | |
width: 30px; | |
} | |
.plus_spell_level_info_100 { | |
font-size: 8px; | |
} | |
.plus_weapon_level_info { | |
position: relative; | |
top: -2px; | |
left: 53px; | |
font-size: 11px; | |
} | |
.plus_weapon_level_info_100 { | |
position: relative; | |
top: -2px; | |
left: 54px; | |
font-size: 8px; | |
} | |
.plus_attribute { | |
float: right; | |
margin-top: 1px; | |
margin-right: -20px; | |
font-size: 12px; | |
text-align: left; | |
width: 35px; | |
} | |
.plus_attribute_small { | |
font-size: 10px; | |
} | |
.plus_spell_button img { | |
opacity: 0.8; | |
} | |
.plus_spell_button img:hover { | |
opacity: 1; | |
} | |
.plus_tooltip { | |
background: url("/img/desk/blk_rgm_back.gif") repeat-y; | |
border: 1px solid #663300; | |
position: absolute; | |
display: none; | |
padding: 4px 8px; | |
max-width: 349px; | |
box-shadow: 0px 0px 20px 0px #663300; | |
z-index: 1000; | |
font-size: 11px; | |
} | |
.plus_tooltip p { | |
margin: 4px; | |
} | |
.map_button { | |
display: block; | |
width: 32px; | |
height: 36px; | |
margin-top: 2px; | |
} | |
// Úprava původních hodnot | |
.all-exp { | |
width: 151px; | |
} | |
.actionpoins { | |
transform: scale(1); | |
color: black; | |
} | |
.autotbl { | |
border-collapse: separate; | |
} | |
#auto-block { | |
height: 57px; | |
} | |
#msg-block p { | |
font-size: 10px; | |
} | |
.hereiam:hover { | |
opacity: 0.3; | |
} | |
.iteminfo { | |
position: relative; | |
} | |
.nabizet { | |
padding: 2px 6px 0px 6px; | |
height: auto; | |
position: absolute; | |
bottom: 0px; | |
width: auto; | |
text-align: center; | |
} | |
`; | |
$('head').append(css); | |
settings.save(); | |
}; | |
if (location.pathname.startsWith('/game/')) { | |
GameScript(); | |
} | |
else { | |
PageScript(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment