Differences
This shows you the differences between the selected revisions of the page.
guide_injecting_sftp_ftp_url_to_page 2017-10-22 | guide_injecting_sftp_ftp_url_to_page 2024-03-18 (current) | ||
Line 10: | Line 10: | ||
===== Example for Amazon EC2 Management Console ===== | ===== Example for Amazon EC2 Management Console ===== | ||
- | Following functional example injects an "Open in WinSCP" link next to //Public %%DNS%%// field on //Instances// page of Amazon EC2 management console. | + | Following functional example injects //"Open in WinSCP"// and //"Open in PuTTY"//((For //"Open in PuTTY"// link to work, you still need WinSCP installed, as WinSCP [[integration_putty#url|handles]] the ''%%ssh://%%'' URL.)) links next to //Public %%DNS%%// field on //Instances// page of Amazon EC2 management console. |
&screenshotpict(ec2_url) | &screenshotpict(ec2_url) | ||
Line 18: | Line 18: | ||
To install the script, install a user script manager to your browser and click on the download link above. | To install the script, install a user script manager to your browser and click on the download link above. | ||
- | * For Mozilla Firefox, use [[https://addons.mozilla.org/en-us/firefox/addon/greasemonkey/|Greasemonkey]] extension; | + | * For Mozilla Firefox, use [[https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/|Greasemonkey]] extension; |
- | * For Google Chrome, use [[https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo|Tampermonkey]] extension.((While Google Chrome supports user scripts on its own, it does not support ''@require'' directive, nor it runs scripts not available in Chrome Web Store.)) | + | * For Google Chrome, use [[https://chromewebstore.google.com/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo|Tampermonkey]] extension.((While Google Chrome supports user scripts on its own, it does not support ''@require'' directive, nor it runs scripts not available in Chrome Web Store.)) |
<code javascript> | <code javascript> | ||
// ==UserScript== | // ==UserScript== | ||
- | // @name WinSCP SFTP URL for Amazon EC2 | + | // @name WinSCP and PuTTY links for Amazon EC2 |
// @namespace https://winscp.net/ | // @namespace https://winscp.net/ | ||
// @author WinSCP | // @author WinSCP | ||
- | // @homepage https://winscp.net/eng/docs/guide_injecting_sftp_ftp_url_to_page | + | // @homepage ~~SELF~~ |
// @description Adds an "Open in WinSCP" link next to "Public DNS" field on Instances page of Amazon EC2 management console | // @description Adds an "Open in WinSCP" link next to "Public DNS" field on Instances page of Amazon EC2 management console | ||
// @include https://*console.aws.amazon.com/* | // @include https://*console.aws.amazon.com/* | ||
// @icon https://winscp.net/pad/winscp.png | // @icon https://winscp.net/pad/winscp.png | ||
- | // @version 1.0 | + | // @version 2.0 |
// @grant none | // @grant none | ||
- | // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js | + | // @require https://code.jquery.com/jquery-3.2.1.min.js |
// ==/UserScript== | // ==/UserScript== | ||
Line 43: | Line 43: | ||
{ | { | ||
var targetNodes = $('span:contains("Public DNS:")'); | var targetNodes = $('span:contains("Public DNS:")'); | ||
- | ···· | + | |
if (targetNodes && targetNodes.length > 0) { | if (targetNodes && targetNodes.length > 0) { | ||
targetNodes.each ( function () { | targetNodes.each ( function () { | ||
Line 50: | Line 50: | ||
// Retrieve hostname | // Retrieve hostname | ||
var hostname = $(this).text().replace("Public DNS:", "").trim(); | var hostname = $(this).text().replace("Public DNS:", "").trim(); | ||
- | // Change the username if needed | + | // Ignore terminated instances |
- | ···············var username = "ec2-user"; | + | if (hostname != "-") { |
- | ···············$(this).append(' – <a href="sftp://' + username + '@' + hostname + '/">Open in WinSCP</a>'); | + | ····················// Change the username if needed |
+ | ···················var username = "ec2-user"; | ||
+ | var uri = '://' + username + '@' + hostname + '/'; | ||
+ | ···················$(this).append( | ||
+ | ························' – <a href="sftp' + uri + '">Open in WinSCP</a>' + | ||
+ | ·······················' &ndash; <a href="ssh' + uri + '">Open in PuTTY</a>'); | ||
+ | } | ||
} | } | ||
} ); | } ); |