Move ShareX.Chrome folder to this repo

This commit is contained in:
Jaex 2016-08-27 01:15:39 +03:00
parent 65f4fc95e2
commit 2f8dcb4f77
12 changed files with 311 additions and 0 deletions

22
ShareX.Chrome.sln Normal file
View file

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareX.Chrome", "ShareX.Chrome\ShareX.Chrome.csproj", "{254E398D-F7F5-4B2A-9024-5C121EA6C564}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Debug|Any CPU.Build.0 = Debug|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Release|Any CPU.ActiveCfg = Release|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -0,0 +1,14 @@
chrome.contextMenus.create({
"id": "ShareX",
"title": "Upload with ShareX",
"contexts": ["selection", "image", "video", "audio"]
});
chrome.contextMenus.onClicked.addListener(onClicked);
function onClicked(info, tab) {
chrome.runtime.sendNativeMessage("com.getsharex.sharex", {
URL: info.srcUrl,
Text: info.selectionText
});
}

View file

@ -0,0 +1,18 @@
{
"manifest_version": 2,
"name": "ShareX",
"version": "1.0.1",
"description": "Adds 'Upload with ShareX' button to image, video, audio and text selection context menu.",
"author": "ShareX Team",
"homepage_url": "https://getsharex.com",
"icons": {
"16": "Icons/ShareX-16.png",
"48": "Icons/ShareX-48.png",
"128": "Icons/ShareX-128.png"
},
"background": {
"persistent": false,
"scripts": [ "eventPage.js" ]
},
"permissions": [ "contextMenus", "nativeMessaging" ]
}

View file

@ -0,0 +1,33 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (c) 2007-2016 ShareX Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
namespace ShareX.Chrome
{
public class ChromeInput
{
public string URL { get; set; }
public string Text { get; set; }
}
}

117
ShareX.Chrome/Program.cs Normal file
View file

@ -0,0 +1,117 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (c) 2007-2016 ShareX Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using Newtonsoft.Json;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
namespace ShareX.Chrome
{
internal class Program
{
private static void Main(string[] args)
{
try
{
Run();
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "ShareX Chrome - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private static void Run()
{
string input = GetInput();
if (!string.IsNullOrEmpty(input))
{
ChromeInput chromeInput = JsonConvert.DeserializeObject<ChromeInput>(input);
if (chromeInput != null)
{
string argument = null;
if (!string.IsNullOrEmpty(chromeInput.URL))
{
argument = EscapeText(chromeInput.URL);
}
else if (!string.IsNullOrEmpty(chromeInput.Text))
{
string filepath = GetTempPath("txt");
File.WriteAllText(filepath, chromeInput.Text, Encoding.UTF8);
argument = EscapeText(filepath);
}
if (!string.IsNullOrEmpty(argument))
{
string path = GetAbsolutePath("ShareX.exe");
Process.Start(path, argument);
}
}
}
}
private static string GetInput()
{
Stream inputStream = Console.OpenStandardInput();
byte[] bytesLength = new byte[4];
inputStream.Read(bytesLength, 0, bytesLength.Length);
int inputLength = BitConverter.ToInt32(bytesLength, 0);
byte[] bytesInput = new byte[inputLength];
inputStream.Read(bytesInput, 0, bytesInput.Length);
return Encoding.UTF8.GetString(bytesInput);
}
private static string EscapeText(string text)
{
return string.Format("\"{0}\"", text.Replace("\\", "\\\\").Replace("\"", "\\\""));
}
public static string GetAbsolutePath(string path)
{
if (!Path.IsPathRooted(path)) // Is relative path?
{
string startupDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
path = Path.Combine(startupDirectory, path);
}
return Path.GetFullPath(path);
}
public static string GetTempPath(string extension)
{
string path = Path.GetTempFileName();
return Path.ChangeExtension(path, extension);
}
}
}

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ShareX Chrome")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ShareX Team")]
[assembly: AssemblyProduct("ShareX")]
[assembly: AssemblyCopyright("Copyright (c) 2007-2016 ShareX Team")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("254e398d-f7f5-4b2a-9024-5c121ea6c564")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{254E398D-F7F5-4B2A-9024-5C121EA6C564}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ShareX.Chrome</RootNamespace>
<AssemblyName>ShareX.Chrome</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChromeInput.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Chrome\manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Chrome\eventPage.js" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
</packages>