GMail Steam URL highlighter

Replace Steam URI's in GMail with actual links

Stan na 21-07-2017. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

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

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         GMail Steam URL highlighter
// @namespace    http://tampermonkey.net/
// @require  https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.slim.min.js
// @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @version      1.0
// @description  Replace Steam URI's in GMail with actual links
// @author       deiga
// @match        https://mail.google.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const steamUrlReplacer = function () {
        const elem = Array.from(document.querySelectorAll('.gs div')).filter(function(item) { return item.textContent.indexOf('steam://') > -1; })[0];
        if (elem) {
            var elemHtml = elem.innerHTML;
            if (elemHtml.indexOf('href="steam://') === -1) {
                elem.innerHTML = elemHtml.replace(/steam:\/\/.*$/m,'<a href="$&">$&</a>').replace('<wbr>','');
            }
        }
    };

    waitForKeyElements (".gs div:contains('steam://')", steamUrlReplacer);
})();