mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-28 23:42:13 +12:00
fixed #6904: Added "Shorten URL with ShareX" support to browser extension
This commit is contained in:
parent
71e9c58b9e
commit
e15141e35a
3 changed files with 36 additions and 8 deletions
|
@ -410,4 +410,14 @@ public enum TaskViewMode // Localized
|
|||
ListView,
|
||||
ThumbnailView
|
||||
}
|
||||
|
||||
public enum NativeMessagingContentType
|
||||
{
|
||||
None,
|
||||
Image,
|
||||
Video,
|
||||
Audio,
|
||||
Text,
|
||||
Link
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ namespace ShareX
|
|||
{
|
||||
public class NativeMessagingInput
|
||||
{
|
||||
public NativeMessagingContentType ContentType { get; set; }
|
||||
public string URL { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
|
|
@ -1912,24 +1912,41 @@ public static void HandleNativeMessagingInput(string filePath)
|
|||
try
|
||||
{
|
||||
nativeMessagingInput = JsonHelpers.DeserializeFromFile<NativeMessagingInput>(filePath);
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
if (nativeMessagingInput != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(nativeMessagingInput.URL) && URLHelpers.IsValidURL(nativeMessagingInput.URL))
|
||||
switch (nativeMessagingInput.ContentType)
|
||||
{
|
||||
case NativeMessagingContentType.Image:
|
||||
case NativeMessagingContentType.Video:
|
||||
case NativeMessagingContentType.Audio:
|
||||
if (!string.IsNullOrEmpty(nativeMessagingInput.URL))
|
||||
{
|
||||
UploadManager.DownloadAndUploadFile(nativeMessagingInput.URL);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(nativeMessagingInput.Text))
|
||||
break;
|
||||
case NativeMessagingContentType.Text:
|
||||
if (!string.IsNullOrEmpty(nativeMessagingInput.Text))
|
||||
{
|
||||
UploadManager.UploadText(nativeMessagingInput.Text);
|
||||
}
|
||||
break;
|
||||
case NativeMessagingContentType.Link:
|
||||
if (!string.IsNullOrEmpty(nativeMessagingInput.URL))
|
||||
{
|
||||
UploadManager.ShortenURL(nativeMessagingInput.URL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue