Adding Clipboard Support to Chrome Extension: Show My IP Addresses (External and Local)


Show My IP Addresses is a Chrome Extension that displays both Local and External IP addresses by one click.

Technology Stack

The Chrome Extension is written in Javascript, that is specifically targeting the Chrome Browser.

New Features

For latest version 0.6.8, I have spent some time adding the Clipboard support so that with one click, the network administrator can copy the addresses to clipboard.

show-my-ip-addresses-ui Adding Clipboard Support to Chrome Extension: Show My IP Addresses (External and Local) chrome extension javascript

show-my-ip-addresses-ui

How to Copy to Clipboard in Chrome Extension?

1
2
3
4
5
6
7
8
9
10
// Copy text to the clipboard.
function copyToClipboard(text, t) {
    var copyFrom = $('<textarea/>');
    copyFrom.text(text);
    $('body').append(copyFrom);
    copyFrom.select();
    document.execCommand('copy');
    copyFrom.remove();
    $(t).html('Copied!');
}
// Copy text to the clipboard.
function copyToClipboard(text, t) {
    var copyFrom = $('<textarea/>');
    copyFrom.text(text);
    $('body').append(copyFrom);
    copyFrom.select();
    document.execCommand('copy');
    copyFrom.remove();
    $(t).html('Copied!');
}

The UI has been simplified quite a bit as well, so that the API log is hidden by default. The users can click to see more data:

show-my-ip-addresses-ui-log Adding Clipboard Support to Chrome Extension: Show My IP Addresses (External and Local) chrome extension javascript

show-my-ip-addresses-ui-log

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
279 words
Last Post: Adding `Image Download List` to the Popular `VideoDownloadHelper` Chrome Extension
Next Post: Adding `Stats` Class to PHP Client of Utopian API

The Permanent URL is: Adding Clipboard Support to Chrome Extension: Show My IP Addresses (External and Local)

Leave a Reply