Direct access 1 click

This commit is contained in:
Natsumi
2022-06-28 21:48:36 +12:00
parent 02ade2a34a
commit 59bb021cd1
3 changed files with 88 additions and 71 deletions
+11
View File
@@ -21,6 +21,7 @@ using librsync.net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace VRCX namespace VRCX
{ {
@@ -453,6 +454,16 @@ namespace VRCX
return output; return output;
} }
public string GetClipboard()
{
var clipboard = String.Empty;
Thread thread = new Thread(() => clipboard = Clipboard.GetText());
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return clipboard;
}
public void SetStartup(bool enabled) public void SetStartup(bool enabled)
{ {
try try
+50 -44
View File
@@ -12342,37 +12342,50 @@ speechSynthesis.getVoices();
callback: (action, instance) => { callback: (action, instance) => {
if (action === 'confirm' && instance.inputValue) { if (action === 'confirm' && instance.inputValue) {
var input = instance.inputValue; var input = instance.inputValue;
var testUrl = input.substring(0, 15); if (!this.directAccessParse(input)) {
if (testUrl === 'https://vrch.at') {
AppApi.FollowUrl(input).then((output) => {
var url = output;
// /home/launch?worldId=wrld_f20326da-f1ac-45fc-a062-609723b097b1&instanceId=33570~region(jp)&shortName=cough-stockinglinz-ddd26
// https://vrch.at/wrld_f20326da-f1ac-45fc-a062-609723b097b1
if (
url.substring(0, 18) ===
'https://vrchat.com'
) {
url = url.substring(18);
}
if (url.substring(0, 13) === '/home/launch?') {
var urlParams = new URLSearchParams(
url.substring(13)
);
var worldId = urlParams.get('worldId');
var instanceId =
urlParams.get('instanceId');
if (instanceId) {
var location = `${worldId}:${instanceId}`;
this.showWorldDialog(location);
} else if (worldId) {
this.showWorldDialog(worldId);
}
} else {
this.$message({ this.$message({
message: 'Invalid URL', message: 'Invalid URL/ID',
type: 'error' type: 'error'
}); });
} }
}
}
}
);
};
$app.methods.directAccessPaste = function () {
AppApi.GetClipboard().then((clipboard) => {
if (!this.directAccessParse(clipboard)) {
this.promptOmniDirectDialog();
}
});
};
$app.methods.directAccessParse = function (input) {
var testUrl = input.substring(0, 15);
if (testUrl === 'https://vrch.at') {
return AppApi.FollowUrl(input).then((output) => {
var url = output;
// /home/launch?worldId=wrld_f20326da-f1ac-45fc-a062-609723b097b1&instanceId=33570~region(jp)&shortName=cough-stockinglinz-ddd26
// https://vrch.at/wrld_f20326da-f1ac-45fc-a062-609723b097b1
if (url.substring(0, 18) === 'https://vrchat.com') {
url = url.substring(18);
}
if (url.substring(0, 13) === '/home/launch?') {
var urlParams = new URLSearchParams(url.substring(13));
var worldId = urlParams.get('worldId');
var instanceId = urlParams.get('instanceId');
if (instanceId) {
var location = `${worldId}:${instanceId}`;
this.showWorldDialog(location);
return true;
} else if (worldId) {
this.showWorldDialog(worldId);
return true;
}
}
return false;
}); });
} else if (testUrl === 'https://vrchat.') { } else if (testUrl === 'https://vrchat.') {
var url = new URL(input); var url = new URL(input);
@@ -12380,14 +12393,15 @@ speechSynthesis.getVoices();
if (urlPath.substring(5, 11) === '/user/') { if (urlPath.substring(5, 11) === '/user/') {
var userId = urlPath.substring(11); var userId = urlPath.substring(11);
this.showUserDialog(userId); this.showUserDialog(userId);
} else if ( return true;
urlPath.substring(5, 13) === '/avatar/' } else if (urlPath.substring(5, 13) === '/avatar/') {
) {
var avatarId = urlPath.substring(13); var avatarId = urlPath.substring(13);
this.showAvatarDialog(avatarId); this.showAvatarDialog(avatarId);
return true;
} else if (urlPath.substring(5, 12) === '/world/') { } else if (urlPath.substring(5, 12) === '/world/') {
var worldId = urlPath.substring(12); var worldId = urlPath.substring(12);
this.showWorldDialog(worldId); this.showWorldDialog(worldId);
return true;
} else if (urlPath.substring(5, 12) === '/launch') { } else if (urlPath.substring(5, 12) === '/launch') {
var urlParams = new URLSearchParams(url.search); var urlParams = new URLSearchParams(url.search);
var worldId = urlParams.get('worldId'); var worldId = urlParams.get('worldId');
@@ -12395,31 +12409,23 @@ speechSynthesis.getVoices();
if (instanceId) { if (instanceId) {
var location = `${worldId}:${instanceId}`; var location = `${worldId}:${instanceId}`;
this.showWorldDialog(location); this.showWorldDialog(location);
return true;
} else if (worldId) { } else if (worldId) {
this.showWorldDialog(worldId); this.showWorldDialog(worldId);
return true;
} }
} else {
this.$message({
message: 'Invalid URL',
type: 'error'
});
} }
} else if (input.substring(0, 4) === 'usr_') { } else if (input.substring(0, 4) === 'usr_') {
this.showUserDialog(input); this.showUserDialog(input);
return true;
} else if (input.substring(0, 5) === 'wrld_') { } else if (input.substring(0, 5) === 'wrld_') {
this.showWorldDialog(input); this.showWorldDialog(input);
return true;
} else if (input.substring(0, 5) === 'avtr_') { } else if (input.substring(0, 5) === 'avtr_') {
this.showAvatarDialog(input); this.showAvatarDialog(input);
} else { return true;
this.$message({
message: 'Invalid ID/URL',
type: 'error'
});
} }
} return false;
}
}
);
}; };
$app.methods.promptNotificationTimeout = function () { $app.methods.promptNotificationTimeout = function () {
+1 -1
View File
@@ -1312,7 +1312,7 @@ html
img.avatar(v-lazy="userImage(item.ref)") img.avatar(v-lazy="userImage(item.ref)")
span(v-else) Search More: #[span(v-text="item.label" style="font-weight:bold")] span(v-else) Search More: #[span(v-text="item.label" style="font-weight:bold")]
el-tooltip(placement="bottom" content="Direct access ID/URL" :disabled="hideTooltips") el-tooltip(placement="bottom" content="Direct access ID/URL" :disabled="hideTooltips")
el-button(type="default" @click="promptOmniDirectDialog()" size="mini" icon="el-icon-discover" circle) el-button(type="default" @click="directAccessPaste" size="mini" icon="el-icon-discover" circle)
el-tooltip(placement="bottom" content="Refresh friends" :disabled="hideTooltips") el-tooltip(placement="bottom" content="Refresh friends" :disabled="hideTooltips")
el-button(type="default" @click="API.closeWebSocket(); API.getCurrentUser(); API.refreshFriends()" :loading="API.isRefreshFriendsLoading" size="mini" icon="el-icon-refresh" circle style="margin-right:10px") el-button(type="default" @click="API.closeWebSocket(); API.getCurrentUser(); API.refreshFriends()" :loading="API.isRefreshFriendsLoading" size="mini" icon="el-icon-refresh" circle style="margin-right:10px")
.x-friend-list(style="padding-bottom:10px") .x-friend-list(style="padding-bottom:10px")