Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ProfileHoverExtension
- // @description Add bacis icons when you mouse over player name.
- // @include http://*.e-sim.org/*
- // @grant none
- // ==/UserScript==
- var m_nPlayerId;
- $(document).ready(function() {
- m_nPlayerId = $("[class='button foundation-style'][href*='profile']").attr('href').replace(/[^0-9]/g, '');
- var aTimer;
- $('[href*="profile.html?id="], [href*="stockCompany.html?id="]').mouseenter(function() {
- var that = this;
- if ($(this).attr('href').indexOf(m_nPlayerId) == -1)
- aTimer = setTimeout(function() {
- showIcons(that);
- }, 1000);
- }).mouseleave(function() {
- clearTimeout(aTimer);
- hideIcons();
- });
- });
- /**
- * show extra icons.
- */
- function showIcons(that) {
- var bIsStock = false;
- if ($(that).attr('href').indexOf("stockCompany") != -1)
- bIsStock = true;
- var aOffset = $(that).offset();
- var nId = $(that).attr("href").replace(/^\D+/g, '');
- var aDiv = $('<div class="testDivblue" id="extTooltip"></div>').css({
- "position": "absolute",
- "top": aOffset.top - 37,
- "left": aOffset.left,
- "background-image": 'url("http://cdn.e-sim.org/img/bg4.png")',
- "border-style": "solid",
- "border-width": 1,
- "border-color": "#777",
- "border-radius": 3
- });
- if (!bIsStock) {
- aDiv.append('<a href="donateEquipment.html?id=' + nId + '"><div class="citizenAction" style="display: flex; align-items: center;"><img style="margin: auto;" src="//cdn.e-sim.org//img/equipment.png" title="Donate equipment" /></div></a>');
- aDiv.append('<a href="donateProducts.html?id=' + nId + '"><div class="citizenAction" style="display: flex; align-items: center;"><img style="margin: auto;" src="//cdn.e-sim.org//img/package.png" class="help" title="Donate items" /></div></a> ');
- aDiv.append('<a href="donateMoney.html?id=' + nId + '"><div class="citizenAction" style="display: flex; align-items: center;"><img style="margin: auto;" src="//cdn.e-sim.org//img/dollar.png" class="help" title="Donate money" /></div></a>');
- aDiv.append('<a href="composeMessage.html?id=' + nId + '"><div class="citizenAction" style="display: flex; align-items: center;"><img style="margin: auto;" src="//cdn.e-sim.org//img/mail.png" class="help" title="Send an ingame message" /></div></a>');
- } else {
- aDiv.append('<a href="stockCompanyDonateMoney.html?id=' + nId + '"><div class="citizenAction" style="display: flex; align-items: center;"><img style="margin: auto;" src="//cdn.e-sim.org//img/dollar.png" class="help" title="Donate money" /></div></a>');
- aDiv.append('<a href="stockCompanyDonateCompany.html?id=' + nId + '"><div class="citizenAction" style="display: flex; align-items: center;"><img style="margin: auto;" src="//cdn.e-sim.org//img/newCompany.png" class="help" title="Send an ingame message" /></div></a>');
- }
- aDiv.mouseleave(function() {
- this.remove();
- });
- $("body").append(aDiv);
- }
- /**
- * hide extra icons.
- */
- function hideIcons() {
- if (typeof $("#extTooltip")[0] != 'undefined') {
- var bIsHovered = $('#extTooltip').is(":hover");
- if (!bIsHovered)
- $("#extTooltip").remove();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment