The code used to make up the My IP: browser extension I designed especially for Dildofox.
Broken down into four parts.
ip.js
/*


*/
const MAX_IP_LENGTH = 45;

const MAIN_API_URL = "https://api.ipify.org/";
const FALLBACK_API_URL = "https://api.ipify.org/";

window.onload = function() {
    fetchClientIP();
};

function fetchClientIP() {
    callAjax(MAIN_API_URL, handler, false);
}

function callAjax(url, callback, isFallback) {
    let xhr = new XMLHttpRequest();
    if (!isFallback) {
        xhr.timeout = 1000;
    }
    xhr.onreadystatechange = function() {
        if (xhr.readyState === 4) {
            if (xhr.status === 200) {
                callback(xhr.responseText, isFallback);
            } else {
                callback(null, isFallback);
            }
        }
    };
    xhr.open("GET", url, true);
    xhr.send();
}

function handler(content, isFallback) {
    if (!content && !isFallback) {
        callAjax(FALLBACK_API_URL, handler, true);
    } else {
        displayContent(content, isFallback);
    }
}

function displayContent(content, isFallback) {
    let ip = 'ERROR';
    if (content && content.length <= MAX_IP_LENGTH) {
        ip = sanitize(content);
    }
    document.getElementById("ip-address").style.color = isFallback ? "purple" : "purple";
    document.getElementById("ip-address").innerText = ip;
}

/**
* @param s
* @returns
*/

function sanitize(s) {
    return s.replace(/[^0-9:a-fA-F.]/g, '');
}
ip.css
#desc {
    text-align: left;
    padding-top: 0;
    margin: 0;
    font-size: 14px;
  }
 
  #ip-address {
    text-align: center;
    -moz-user-select: text;
    user-select: text;
    cursor: text;
    font-size: 16px;
  }
 
  #img-container {
    text-align: center;
  }
index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <link href="ip.css" rel="stylesheet" type="text/css">
</head>
<body>
  <div id="root">
    <h3 id="desc">My IP:</h3>
    <pre id="ip-address">Obtaining IP...</pre>
    <div id="img-container">
    </div>
  </div>
  <script src="ip.js"></script>
</body>
</html>
README.md
This extension is a re-packaged edit based on "show-my-ip" by TwinProduction.

While using his and other IP fetching extensions, I found that most, if not all of them would return errors while connected to VPN's, TOR or other Proxies and not return the IP result.

I used the base script from TwinProduction's extension and changed things around a bit and now the extension will always return your IP with no errors, even while using the TOR or any other proxy service.

The extension can be added to your Firefox browser from https://addons.mozilla.org/en-US/firefox/addon/my-ip/

Alternatively you can download the .xpi file from this GitHub page under the releases section.

All credit goes to Twin for writing the base script and allowing us to modify his code.
Source Code
My IP:
dildofox.com
A Customized Firefox Fork Optimized for
Free Speech, Privacy & Security