Astral WoWProgress Character Information Decorator

Add Astral recruitment decoration to WCL pages

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Astral WoWProgress Character Information Decorator
// @namespace    https://www.wowprogress.com
// @version      0.03
// @description  Add Astral recruitment decoration to WCL pages
// @author       Pewbies / Faignz
// @match        https://www.wowprogress.com/character/*/*/*
// @icon         https://www.astralguild.com/styles/astral/xenforo/xenforo-logo.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    addAstralButton();

    const buildListOfLinks = ( characterUrl ) => {
        return [
            { 'service': 'Raider IO', 'image': 'https://cdn.raiderio.net/images/favicon-32x32.png', 'url': `https://raider.io/characters/${ characterUrl }` },
            { 'service': 'Warcraft Logs', 'image': 'https://assets.rpglogs.com/img/warcraft/favicon.png', 'url': `https://www.warcraftlogs.com/character/${ characterUrl }` },
        ]
    }

    window.startProcessing = function( characterUrl ) {
        if ( characterUrl ) { addAstralLinks(characterUrl); }
        else { alertUser( 'Please view a character then click this button again.' ); }
    }

    function addAstralLinks( characterUrl ) {
        const linkObj = buildListOfLinks( characterUrl );
        console.log(linkObj);
        const displayHtml = linkObj.reduce( (acc, curr) => {
            acc += `<a href = '${ curr.url }' target='_blank'> <img src='${ curr.image }' style='height:32px;'/> </a>&nbsp;&nbsp`;
            return acc;
        }, '')
        addLinkDisplay( displayHtml );
    }

    function addLinkDisplay(displayHtml) {
        console.log(displayHtml);
        const div = document.createElement('div');
        div.innerHTML = ( `<div class='astralLinks' style='position: fixed; top: 30px; right: 0; z-index: 99999; height: 32px; background-color: #111826;' >${ displayHtml }</div>`);
        document.body.prepend(div);
    }

    function addAstralButton() {
        const div = document.createElement('div');
        div.innerHTML = ( `<button class='addAstralLinks' style='position: fixed; top: 0; right: 0; z-index: 99999; height: 30px; background-repeat: no-repeat; background-size: contain; width: 100px; background-color: #111826; background-image:url("https://www.astralguild.com/styles/astral/xenforo/xenforo-logo.png")' onclick='startProcessing(checkForCharacterPage())'/></button>`);
        document.body.prepend(div);
    }

    window.checkForCharacterPage = function() { return window.location.href.split('character/')[1].replace('-','') || false; }

    function alertUser( message ) { alert(message); }
})();