-
-
Save bygreencn/1058b78be1c0b516109e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ShadowX Profile | |
// @namespace com.gmail.open.xuyiming | |
// @version 0.1 | |
// @description 在 ShadowX 的节点页面显示 JSON 格式的配置文件 | |
// @author +依然独特 | |
// @match *://shadowx.work/user/node/* | |
// @match *://shadowx.co/user/node/* | |
// @include *://shadowx.work/user/node/* | |
// @include *://shadowx.co/user/node/* | |
// @grant none | |
// ==/UserScript== | |
( function() { | |
document.addEventListener( "DOMContentLoaded", function() { | |
var info_box, link_p, profile, p, | |
qrcode = document.getElementById( "qrcode" ); | |
if ( qrcode ) { | |
info_box = qrcode.parentElement.parentElement; | |
link_p = info_box.getElementsByTagName( "p" )[0]; | |
profile = decodeSSProfile( link_p.textContent.trim() ); | |
p = document.createElement( "pre" ); | |
p.innerHTML = "{" + "\n" + | |
"\t" + "\"server\": " + profile.server + ",\n" + | |
"\t" + "\"server_port\": " + profile.server_port + ",\n" + | |
"\t" + "\"password\": " + profile.password + ",\n" + | |
"\t" + "\"method\": " + profile.method + "\n" + | |
"}"; | |
info_box.insertBefore( p, link_p ); | |
} | |
}, false ); | |
function decodeSSProfile( ss ) { | |
var config = atob( ss.replace( /^ss:\/\//, "" ) ) | |
.split( "@" ) | |
.map( function( part ) { | |
return part.split( ":" ); | |
} ); | |
return { | |
"server": config[ 1 ][ 0 ], | |
"server_port": parseInt( config[ 1 ][ 1 ], 10 ), | |
"password": config[ 0 ][ 1 ], | |
"method": config[ 0 ][ 0 ] | |
}; | |
}; | |
} )(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment