Skip to content

TamperMonkey script to make getting the portal text easier #30

Open
@djpeach

Description

Its ugly, its probably not perfect, but it works on everything I've used so far. It just allows you to easily copy the title and link of the portal to your clipboard. Click the portal, click the link button and voila you got it in your clipboard. Wasnt sure where else to share it.

// @name         Ingress Portal Copyer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://intel.ingress.com/intel?state=GOOGLE&code=4%2F0AY0e-g6DQpl2zaTtquTbcWFZZa_lRG_dE6sWsw8ICgrWbIJtGbshNWdvSWEYrowtnE7hgg&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+openid&authuser=2&prompt=consent
// @grant        none
// ==/UserScript==

(function() {
    function copyToClipboard(text) {
        const elem = document.createElement('textarea');
        elem.value = text;
        document.body.appendChild(elem);
        elem.select();
        document.execCommand('copy');
        document.body.removeChild(elem);
    }

    'use strict';

    let linkButton = document.getElementById("header_maplink");

    linkButton.addEventListener("click", function() {

        let title = "";
        let link = "";
        let portalText = "";

        let titleEl = document.getElementById("portal_primary_title");
        let linkEl = document.getElementById("maplink");

        if (titleEl) {
            title = titleEl.innerHTML.replace(/["]+/g, '').replace(/(&)+/g, "&");
        }
        if (linkEl) {
            link = linkEl.value;
        }

        portalText = title + "; " + link;
        copyToClipboard(portalText);
        console.log(portalText);
    });

})();```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions