Metacritic: IGGGAMES Search

Adds an igg-games.com search link to Metacritic game pages

// ==UserScript==
// @name         Metacritic: IGGGAMES Search
// @description  Adds an igg-games.com search link to Metacritic game pages
// @version      0.5
// @author       mica
// @namespace    greasyfork.org/users/12559
// @match        https://www.metacritic.com/*
// @license      MIT
// ==/UserScript==

function makeLink() {
    const title = document.querySelector('.c-productHero_title').innerText.replace(':', '');
    const div = document.createElement('div');
        div.style.marginTop = '15px';
    const a = document.createElement('a');
        a.href = 'https://igg-games.com/?s=' + encodeURIComponent(title);
    const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
        svg.setAttribute('width', '20px');
        svg.setAttribute('height', '20px');
    const image = document.createElementNS('http://www.w3.org/2000/svg', 'image');
        image.setAttribute('width', '20px');
        image.setAttribute('height', '20px');
        image.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAABGdBTUEAALGPC/xhBQAAACBjSFJN AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElN RQflCAgJIytiXfYRAAABA0lEQVQY0wXBPUoDURQG0O/edyeRJGSIyaCBRK2M4A9CUNyA5SC4ADsb V+AirF2CkMrOJoKVoKDNgBgbmyAGi8HBkDHOe+96DiXTtBHl44IAQINIak+DE756sCUAWrRPxcw+ 7eNNcy/0CviwLspEWemsN5wxwDUWAPDlVYyygN3rQlcA4vLPYGerYEnfYQTq7HZneEcgWDpcE5DL d8+TOQPwrf06AwR13qt6pa/bsUBN5fliUqlCoX/L6wJi8zKJ++mclVBtCqDe1o/NdRaAXKsrBCjy Ua8/MyYbfsQC76llLzeqHvyddUJxlbY5OLp/C0gVm/EKJdO0Ef2O50xQXVwq/gEMXWip8KP0OQAA ACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wOC0wOFQwOTozNTo0MyswMzowMD5PnNwAAAAldEVYdGRh dGU6bW9kaWZ5ADIwMjEtMDgtMDhUMDk6MzU6NDMrMDM6MDBPEiRgAAAAAElFTkSuQmCC');
    const span = document.createElement('span');
        span.style.position = 'relative';
        span.style.top = '-4px';
        span.style.left = '6px';
        span.style.fontSize = '115%';
        span.innerText = 'Search IGGGAMES';
    svg.append(image);
    a.append(svg, span);
    div.append(a);
    document.querySelector('.c-productHero_score-container > .g-text-xsmall').append(div);
}

let url;
setInterval(() => {
    if (url != location.href) {
        url = location.href;
        if (location.pathname.match('\/game\/.') && document.querySelector('.c-gamePlatformLogo_icon.c-gamePlatformLogo_icon--PCLogo')) {
            setTimeout(() => {
                makeLink();
            }, 900);
        }
    }
}, 300);