如何在Chrome浏览器中自动将S3 URL转换为HTTP链接并跳转至AWS S3控制台?
如何在Chrome浏览器中自动将S3 URL转换为HTTP链接并跳转至AWS S3控制台?
当然可以啦!给你分享两个简单好用的方法,能帮你在Chrome里轻松处理S3 URL转AWS控制台链接的需求,不用再手动修改格式啦:
方法一:使用Tampermonkey用户脚本(自动跳转)
这个方法能实现自动识别并跳转——不管是你直接在地址栏输入的s3://链接,还是网页上的S3链接,都会自动转换成控制台链接并跳转。步骤如下:
- 打开Chrome应用商店,搜索并安装Tampermonkey扩展(这是一款常用的用户脚本管理工具)
- 点击Tampermonkey图标,选择「创建新脚本」
- 删掉默认的脚本内容,替换成下面这段代码:
// ==UserScript== // @name S3 URL to Console Redirect // @namespace http://tampermonkey.net/ // @version 0.1 // @description Automatically convert s3:// URLs to AWS S3 Console links // @author You // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; // Function to convert S3 URL to console URL function convertS3Url(s3Url) { // Remove the s3:// prefix const withoutPrefix = s3Url.replace('s3://', ''); // Split into bucket and the rest (including query params) const [bucket, ...restParts] = withoutPrefix.split('/'); const rest = restParts.join('/'); // Build the console URL return `https://s3.console.aws.amazon.com/s3/buckets/${bucket}?${rest.includes('?') ? rest.split('?')[1] : `prefix=${rest}`}`; } // Check if current page is an S3 URL (Chrome throws error, so we intercept it) const currentUrl = window.location.href; if (currentUrl.startsWith('s3://')) { const consoleUrl = convertS3Url(currentUrl); window.location.replace(consoleUrl); } // Convert all s3:// links on web pages document.querySelectorAll('a[href^="s3://"]').forEach(link => { const consoleUrl = convertS3Url(link.href); link.href = consoleUrl; }); })();
- 按下
Ctrl+S保存脚本,之后再输入s3://mybucket/mybucket?prefix=myprefix/file.json这类链接,Chrome就会自动跳转到对应的S3控制台页面啦!
方法二:自定义Chrome搜索引擎(手动快速转换)
如果你不想装扩展,这个方法适合手动快速转换S3路径:
- 打开Chrome的设置页面,找到「搜索引擎」选项
- 点击「管理搜索引擎和网站搜索」
- 点击页面下方的「添加」按钮,填写以下内容:
- 搜索引擎名称:随便取,比如「S3控制台跳转」
- 关键字:比如
s3(方便你快速调用) - 查询URL:
https://s3.console.aws.amazon.com/s3/buckets/%s
- 保存设置后,当你想转换S3路径时,只需要在地址栏输入
s3,按下空格,再输入mybucket/mybucket?prefix=myprefix/file.json,按下回车就能直接跳转到控制台页面啦!
备注:内容来源于stack exchange,提问作者Cherry
相关产品推荐
相关产品推荐

