UD Underline Related Profile Links

Modernized take on Bradley Sattem's (a.k.a. Aichon) idea to underlined all related profile links on mouse hover

2024-06-06 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

// ==UserScript==
// @name        UD Underline Related Profile Links
// @namespace   Avarice77
// @match       https://urbandead.com/map.cgi*
// @match       https://www.urbandead.com/map.cgi*
// @grant       none
// @license     MIT
// @version     1.0
// @author      Avarice77
// @description Modernized take on Bradley Sattem's (a.k.a. Aichon) idea to underlined all related profile links on mouse hover
// ==/UserScript==

const profileEl = document.querySelectorAll('.gt')[0].querySelector('a');
const playerId = profileEl.href.substring(profileEl.href.indexOf('id=') + 3);
const allProfiles = Array.from(document.querySelectorAll('a[href^="profile.cgi"]:not(.y)'));
allProfiles.forEach((profile) => {
  if (!profile.href.includes(playerId)) {
    const profileId = profile.href.substring(profile.href.indexOf('id=') + 3);
    profile.addEventListener('mouseover', (e) => {
      allProfiles.forEach((otherProfile) => {
        const otherProfileId = otherProfile.href.substring(otherProfile.href.indexOf('id=') + 3);
        if (otherProfileId === profileId) {
          otherProfile.style.textDecoration = 'underline';
        } else {
          otherProfile.style.textDecoration = 'none';
        }
      });
    });
    profile.addEventListener('mouseout', (e) => {
      allProfiles.forEach((profile) => {
        profile.style.textDecoration = 'none';
      });
    });
 }
});