improved add-on support

improved add-on support
This commit is contained in:
hama3254 2021-02-12 13:44:17 +01:00
parent f16c9715bb
commit 44ffb1a99b
16 changed files with 235 additions and 105 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Crunchyroll Downloader Addon", "name": "Crunchyroll Downloader Addon",
"version": "0.3.0", "version": "0.4.0",
"description": "A Firefox Addon for my Crunchyroll Downloader", "description": "A Firefox Addon for my Crunchyroll Downloader",
@ -9,8 +9,7 @@
"48": "icons/icon-48.png" "48": "icons/icon-48.png"
}, },
"permissions": [ "permissions": [
"*://anime-on-demand.de/*", "storage",
"*://www.anime-on-demand.de/*",
"activeTab", "activeTab",
"cookies", "cookies",
"tabs" "tabs"

View File

@ -12,4 +12,19 @@
margin-Bottom:12px; margin-Bottom:12px;
border-radius: 12px; border-radius: 12px;
cursor:pointer; cursor:pointer;
}
.txt_class {
background-color: #ebe9e8;
border: none;
color: black;
padding: 10px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin-left:12px;
margin-right:12px;
margin-Top:12px;
margin-Bottom:12px;
border-radius: 12px;
cursor:pointer;
} }

View File

@ -24,9 +24,10 @@
<button type="button" class='btn_class' id='btn_enable_select'>Select Episodes</button> <button type="button" class='btn_class' id='btn_enable_select'>Select Episodes</button>
<button type="button" class='btn_class' id='btn_select_all'>Select All</button> <button type="button" class='btn_class' id='btn_select_all'>Select All</button>
<button type="button" class='btn_class' id='btn_select_none'>Deselect All</button> <button type="button" class='btn_class' id='btn_select_none'>Deselect All</button>
<input name="captchaText" id="txtInput" class='txt_class' type="text" value="">
</div> <button type="button" class='btn_class' id='btn_set_port'>Set Port</button>
<iframe src="http://127.0.0.1" id="CRD-Webserver" width="760px" height="320px" frameborder="0"></iframe> </div>
<iframe src="http://127.0.0.1:80" id="CRD-Webserver" width="760px" height="320px" frameborder="0"></iframe>
</center> </center>
<script type="text/javascript" src="popup.js"></script> <script type="text/javascript" src="popup.js"></script>
</body> </body>

View File

@ -1,47 +1,129 @@
browser.tabs.query({ var Port;
currentWindow: true, document.getElementById("btn_add").hidden = true;
active: true document.getElementById("btn_enable_select").hidden = true;
}).then((tabs) => { document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true;
document.getElementById("CRD-Webserver").hidden = true;
let tab = tabs[0]; // Safe to assume there will only be one resultconsole.log(tab.url);
console.log(tab.url);
if (tab.url.includes('crunchyroll.com')) {
var crunchyroll = browser.tabs.executeScript({
code: 'document.getElementsByClassName("episode")[0].href;'
});
crunchyroll.then(onExecuted, onError);
} else if (tab.url.includes('funimation.com')) { function setItem() {
console.log("OK");
}
function notsetItem() {
console.log("Not OK");
}
var funimation = browser.tabs.executeScript({ browser.storage.local.get("CRD_Port")
.then(gotPort, NoPort);
code: 'document.getElementsByClassName("trackVideo")[0].href' function gotPort(result) {
}); try {
funimation.then(FunimationSuccess, FunimationError); onStartup(result.CRD_Port.value);
} else if (tab.url.includes('anime-on-demand.de/anime/')) { console.log("Port: " + result.CRD_Port.value)
} catch (e) {
document.getElementById("btn_add").hidden = true; onStartup(80);
document.getElementById("btn_enable_select").hidden = true; console.log("no port")
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true; //false if implemented
} else {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_enable_select").hidden = true;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true;
} }
}, console.error)
}
function NoPort(result) {
//onStartup(80);
console.log("no port")
}
function onStartup(result) {
console.log(result);
Port = result;
const xhr = new XMLHttpRequest(),
method = "GET",
url = "http://localhost:" + Port + "/CRD_Handshake";
xhr.open(method, url, true);
xhr.onreadystatechange = function () {
// In local files, status is 0 upon success in Mozilla Firefox
if (xhr.readyState === XMLHttpRequest.DONE) {
//var status = xhr.status;
//status === 0 || (status >= 200 && status < 400)
console.log(xhr.responseText);
if (xhr.responseText == "CRD_Handshake_Confirm") {
document.getElementById("txtInput").hidden = true;
document.getElementById("btn_set_port").hidden = true;
document.getElementById("CRD-Webserver").hidden = false
document.getElementById("CRD-Webserver").src = "http://localhost:" + Port;
// The request has been completed successfully
browser.tabs.query({
currentWindow: true,
active: true
}).then((tabs) => {
let tab = tabs[0]; // Safe to assume there will only be one resultconsole.log(tab.url);
console.log(tab.url);
if (tab.url.includes('crunchyroll.com')) {
var crunchyroll = browser.tabs.executeScript({
code: 'document.getElementsByClassName("episode")[0].href;'
});
crunchyroll.then(onExecuted, onError);
} else if (tab.url.includes('funimation.com')) {
var funimation = browser.tabs.executeScript({
code: 'document.getElementsByClassName("trackVideo")[0].href'
});
funimation.then(FunimationSuccess, FunimationError);
} else if (tab.url.includes('anime-on-demand.de/anime/')) {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_enable_select").hidden = true;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true; //false if implemented
} else {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_enable_select").hidden = true;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true;
}
}, console.error)
i = 91;
} else {
console.log("No CRD found");
// Oh no! There has been an error with the request!
}
}
};
xhr.send();
}
document.getElementById('btn_set_port').addEventListener('click', () => {
let CRD_Port = {
value: document.getElementById('txtInput').value
}
browser.storage.local.set({
CRD_Port
})
.then(setItem, notsetItem);
window.close();
});
document.getElementById('btn_add_AoD').addEventListener('click', () => { document.getElementById('btn_add_AoD').addEventListener('click', () => {
//browser.cookies.getAllCookieStores().then((cookie) => { //browser.cookies.getAllCookieStores().then((cookie) => {
@ -63,7 +145,7 @@ document.getElementById('btn_add_AoD').addEventListener('click', () => {
document.getElementById('btn_enable_select').addEventListener('click', () => { document.getElementById('btn_enable_select').addEventListener('click', () => {
browser.tabs.executeScript({ browser.tabs.executeScript({
code: 'var script=document.createElement("script");script.type="text/javascript",script.src="http://127.0.0.1/inject.js",document.head.appendChild(script);' code: 'var script=document.createElement("script");script.type="text/javascript",script.src="http://127.0.0.1:'+Port+'/inject.js",document.head.appendChild(script);'
}); //load script from local CRD Server included in https://github.com/hama3254/Crunchyroll-Downloader-v3.0 }); //load script from local CRD Server included in https://github.com/hama3254/Crunchyroll-Downloader-v3.0
document.getElementById("btn_add_mass").hidden = false; document.getElementById("btn_add_mass").hidden = false;
@ -201,7 +283,7 @@ function add_fun_ok(result) {
document.getElementById("btn_add_funimation").style.background = "#c9c9c9" document.getElementById("btn_add_funimation").style.background = "#c9c9c9"
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://127.0.0.1/post", true); xhttp.open("POST", "http://127.0.0.1:"+Port+"/post", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("FunimationURL=" + tab.url); xhttp.send("FunimationURL=" + tab.url);
@ -221,7 +303,7 @@ function add_one_ok(result) {
document.getElementById("btn_add").style.background = "#c9c9c9" document.getElementById("btn_add").style.background = "#c9c9c9"
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://127.0.0.1/post", true); xhttp.open("POST", "http://127.0.0.1:"+Port+"/post", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("HTMLSingle=" + result); xhttp.send("HTMLSingle=" + result);
@ -243,7 +325,7 @@ function add_mass_ok(result) {
document.getElementById("btn_add_mass").style.background = "#c9c9c9" document.getElementById("btn_add_mass").style.background = "#c9c9c9"
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://127.0.0.1/post", true); xhttp.open("POST", "http://127.0.0.1:"+Port+"/post", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("HTMLMass=" + result); xhttp.send("HTMLMass=" + result);
@ -264,7 +346,7 @@ function add_mass_error(error) {
document.getElementById('btn_enable_funimation_select').addEventListener('click', () => { document.getElementById('btn_enable_funimation_select').addEventListener('click', () => {
browser.tabs.executeScript({ browser.tabs.executeScript({
code: 'var script=document.createElement("script");script.type="text/javascript",script.src="http://127.0.0.1/inject_funimation.js",document.head.appendChild(script);' code: 'var script=document.createElement("script");script.type="text/javascript",script.src="http://127.0.0.1:'+Port+'/inject_funimation.js",document.head.appendChild(script);'
}); //load script from local CRD Server included in https://github.com/hama3254/Crunchyroll-Downloader-v3.0 }); //load script from local CRD Server included in https://github.com/hama3254/Crunchyroll-Downloader-v3.0
document.getElementById("btn_add_mass").hidden = false; document.getElementById("btn_add_mass").hidden = false;

View File

@ -29,7 +29,7 @@ Public Class Main
Dim ItemList As New List(Of CRD_List_Item) Dim ItemList As New List(Of CRD_List_Item)
Public RunningDownloads As Integer = 0 Public RunningDownloads As Integer = 0
Public UseQueue As Boolean = False Public UseQueue As Boolean = False
Public StartServer As Boolean = False Public StartServer As Integer = 0
Public m3u8List As New List(Of String) Public m3u8List As New List(Of String)
Public txtList As New List(Of String) Public txtList As New List(Of String)
Public mpdList As New List(Of String) Public mpdList As New List(Of String)
@ -333,11 +333,11 @@ Public Class Main
Try Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader") Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
StartServer = CBool(Integer.Parse(rkg.GetValue("StartServer").ToString)) StartServer = Integer.Parse(rkg.GetValue("ServerPort").ToString)
Catch ex As Exception Catch ex As Exception
End Try End Try
If StartServer = True Then If StartServer > 0 Then
Timer3.Enabled = True Timer3.Enabled = True
ServerThread = New Thread(AddressOf ServerStart) ServerThread = New Thread(AddressOf ServerStart)
ServerThread.Priority = ThreadPriority.Normal ServerThread.Priority = ThreadPriority.Normal
@ -2920,13 +2920,15 @@ Public Class Main
Exit Sub Exit Sub
End If End If
Dim serverIP As IPAddress = Dns.GetHostEntry(hostName).AddressList(Adresscount) 'Dns.Resolve(hostName).AddressList(0) 'New IPAddress("localhost") ' Dim serverIP As IPAddress = Dns.GetHostEntry(hostName).AddressList(Adresscount) 'Dns.Resolve(hostName).AddressList(0) 'New IPAddress("localhost") '
' Web Server Port = 80
Dim Port As String = "80" Dim Port As String = StartServer
tcpListener = New TcpListener(serverIP, Int32.Parse(Port)) tcpListener = New TcpListener(serverIP, Int32.Parse(Port))
tcpListener.Start() tcpListener.Start()
Debug.WriteLine("Web server started at: " & serverIP.ToString() & ":" & Port) Debug.WriteLine("Web server started at: " & serverIP.ToString() & ":" & Port)
ProcessThread() ProcessThread()
Catch abort As ThreadAbortException Catch abort As ThreadAbortException
Exit Sub Exit Sub
@ -2983,8 +2985,9 @@ Public Class Main
If strArray(0).Trim().ToUpper.Equals("POST") Then If strArray(0).Trim().ToUpper.Equals("POST") Then
Debug.WriteLine("receiving data from the add-on") 'Debug.WriteLine("receiving data from the add-on")
Debug.WriteLine(UrlDecode(htmlReq)) 'Debug.WriteLine(UrlDecode(htmlReq))
Me.Invoke(New Action(Function() Me.Invoke(New Action(Function()
Me.Text = "Status: receiving data from the add-on" Me.Text = "Status: receiving data from the add-on"
Me.Invalidate() Me.Invalidate()
@ -3219,6 +3222,12 @@ Public Class Main
ElseIf strArray(0).Trim().ToUpper.Equals("GET") Then ElseIf strArray(0).Trim().ToUpper.Equals("GET") Then
If InStr(htmlReq, "CRD_Handshake") Then
SendHTMLResponse("Handshake_Confirm", clientSocket)
Exit Sub
End If
strRequest = strArray(1).Trim strRequest = strArray(1).Trim
If strRequest.StartsWith("/") Then If strRequest.StartsWith("/") Then
@ -3277,6 +3286,21 @@ Public Class Main
' Close HTTP Socket connection ' Close HTTP Socket connection
clientSocket.Shutdown(SocketShutdown.Both) clientSocket.Shutdown(SocketShutdown.Both)
clientSocket.Close() clientSocket.Close()
ElseIf httpRequest = "Handshake_Confirm" Then
respByte = System.Text.Encoding.UTF8.GetBytes("CRD_Handshake_Confirm") 'File.ReadAllBytes("") '
Dim htmlHeader As String =
"HTTP/1.0 200 OK" & ControlChars.CrLf &
"Server: CRD 1.0" & ControlChars.CrLf &
"Access-Control-Allow-Origin: *" & ControlChars.CrLf &
"Content-Length: " & respByte.Length & ControlChars.CrLf &
"Content-Type: text/plain" &
ControlChars.CrLf & ControlChars.CrLf
Dim headerByte() As Byte = Encoding.UTF8.GetBytes(htmlHeader)
clientSocket.Send(headerByte, 0, headerByte.Length, SocketFlags.None)
clientSocket.Send(respByte, 0, respByte.Length, SocketFlags.None)
clientSocket.Shutdown(SocketShutdown.Both)
clientSocket.Close()
Else Else
respByte = Encoding.UTF8.GetBytes(My.Resources.Error_404) 'File.ReadAllBytes(httpRequest) respByte = Encoding.UTF8.GetBytes(My.Resources.Error_404) 'File.ReadAllBytes(httpRequest)

View File

@ -97,8 +97,8 @@ Partial Class Einstellungen
Me.Label2 = New MetroFramework.Controls.MetroLabel() Me.Label2 = New MetroFramework.Controls.MetroLabel()
Me.NumericUpDown2 = New System.Windows.Forms.NumericUpDown() Me.NumericUpDown2 = New System.Windows.Forms.NumericUpDown()
Me.GroupBox5 = New System.Windows.Forms.GroupBox() Me.GroupBox5 = New System.Windows.Forms.GroupBox()
Me.http_support = New MetroFramework.Controls.MetroComboBox()
Me.DarkMode = New MetroFramework.Controls.MetroCheckBox() Me.DarkMode = New MetroFramework.Controls.MetroCheckBox()
Me.Server = New MetroFramework.Controls.MetroCheckBox()
Me.CB_Log = New MetroFramework.Controls.MetroCheckBox() Me.CB_Log = New MetroFramework.Controls.MetroCheckBox()
Me.ListViewAdd_True = New MetroFramework.Controls.MetroCheckBox() Me.ListViewAdd_True = New MetroFramework.Controls.MetroCheckBox()
Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.GroupBox1 = New System.Windows.Forms.GroupBox()
@ -607,10 +607,10 @@ Partial Class Einstellungen
Me.TabPage2.HorizontalScrollbarBarColor = True Me.TabPage2.HorizontalScrollbarBarColor = True
Me.TabPage2.HorizontalScrollbarHighlightOnWheel = False Me.TabPage2.HorizontalScrollbarHighlightOnWheel = False
Me.TabPage2.HorizontalScrollbarSize = 10 Me.TabPage2.HorizontalScrollbarSize = 10
Me.TabPage2.Location = New System.Drawing.Point(4, 44) Me.TabPage2.Location = New System.Drawing.Point(4, 35)
Me.TabPage2.Name = "TabPage2" Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Padding = New System.Windows.Forms.Padding(3) Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage2.Size = New System.Drawing.Size(493, 452) Me.TabPage2.Size = New System.Drawing.Size(493, 461)
Me.TabPage2.TabIndex = 1 Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "Output" Me.TabPage2.Text = "Output"
Me.TabPage2.VerticalScrollbarBarColor = True Me.TabPage2.VerticalScrollbarBarColor = True
@ -970,10 +970,10 @@ Partial Class Einstellungen
Me.TabPage1.HorizontalScrollbarBarColor = True Me.TabPage1.HorizontalScrollbarBarColor = True
Me.TabPage1.HorizontalScrollbarHighlightOnWheel = False Me.TabPage1.HorizontalScrollbarHighlightOnWheel = False
Me.TabPage1.HorizontalScrollbarSize = 10 Me.TabPage1.HorizontalScrollbarSize = 10
Me.TabPage1.Location = New System.Drawing.Point(4, 35) Me.TabPage1.Location = New System.Drawing.Point(4, 44)
Me.TabPage1.Name = "TabPage1" Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Padding = New System.Windows.Forms.Padding(3) Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage1.Size = New System.Drawing.Size(493, 461) Me.TabPage1.Size = New System.Drawing.Size(493, 452)
Me.TabPage1.TabIndex = 0 Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = " Main" Me.TabPage1.Text = " Main"
Me.TabPage1.VerticalScrollbar = True Me.TabPage1.VerticalScrollbar = True
@ -1039,8 +1039,8 @@ Partial Class Einstellungen
'GroupBox5 'GroupBox5
' '
Me.GroupBox5.BackColor = System.Drawing.Color.Transparent Me.GroupBox5.BackColor = System.Drawing.Color.Transparent
Me.GroupBox5.Controls.Add(Me.http_support)
Me.GroupBox5.Controls.Add(Me.DarkMode) Me.GroupBox5.Controls.Add(Me.DarkMode)
Me.GroupBox5.Controls.Add(Me.Server)
Me.GroupBox5.Controls.Add(Me.CB_Log) Me.GroupBox5.Controls.Add(Me.CB_Log)
Me.GroupBox5.Controls.Add(Me.ListViewAdd_True) Me.GroupBox5.Controls.Add(Me.ListViewAdd_True)
Me.GroupBox5.Font = New System.Drawing.Font("Arial", 9.75!) Me.GroupBox5.Font = New System.Drawing.Font("Arial", 9.75!)
@ -1052,6 +1052,21 @@ Partial Class Einstellungen
Me.GroupBox5.TabStop = False Me.GroupBox5.TabStop = False
Me.GroupBox5.Text = "Other" Me.GroupBox5.Text = "Other"
' '
'http_support
'
Me.http_support.DropDownHeight = 250
Me.http_support.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown
Me.http_support.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.http_support.FormattingEnabled = True
Me.http_support.IntegralHeight = False
Me.http_support.ItemHeight = 23
Me.http_support.Items.AddRange(New Object() {"add-on support disabled", "80", "8080"})
Me.http_support.Location = New System.Drawing.Point(214, 70)
Me.http_support.Name = "http_support"
Me.http_support.Size = New System.Drawing.Size(237, 29)
Me.http_support.TabIndex = 45
Me.http_support.UseSelectable = True
'
'DarkMode 'DarkMode
' '
Me.DarkMode.AutoSize = True Me.DarkMode.AutoSize = True
@ -1062,17 +1077,6 @@ Partial Class Einstellungen
Me.DarkMode.Text = "enable dark mode" Me.DarkMode.Text = "enable dark mode"
Me.DarkMode.UseSelectable = True Me.DarkMode.UseSelectable = True
' '
'Server
'
Me.Server.AutoSize = True
Me.Server.FontSize = MetroFramework.MetroCheckBoxSize.Medium
Me.Server.Location = New System.Drawing.Point(214, 75)
Me.Server.Name = "Server"
Me.Server.Size = New System.Drawing.Size(246, 19)
Me.Server.TabIndex = 43
Me.Server.Text = "enable http server (add-on Support)"
Me.Server.UseSelectable = True
'
'CB_Log 'CB_Log
' '
Me.CB_Log.AutoSize = True Me.CB_Log.AutoSize = True
@ -1186,7 +1190,7 @@ Partial Class Einstellungen
Me.TabControl1.FontWeight = MetroFramework.MetroTabControlWeight.Regular Me.TabControl1.FontWeight = MetroFramework.MetroTabControlWeight.Regular
Me.TabControl1.Location = New System.Drawing.Point(22, 60) Me.TabControl1.Location = New System.Drawing.Point(22, 60)
Me.TabControl1.Name = "TabControl1" Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 1 Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(501, 500) Me.TabControl1.Size = New System.Drawing.Size(501, 500)
Me.TabControl1.TabIndex = 38 Me.TabControl1.TabIndex = 38
Me.TabControl1.UseSelectable = True Me.TabControl1.UseSelectable = True
@ -1712,7 +1716,6 @@ Partial Class Einstellungen
Public WithEvents Label6 As MetroFramework.Controls.MetroLabel Public WithEvents Label6 As MetroFramework.Controls.MetroLabel
Public WithEvents Label5 As MetroFramework.Controls.MetroLabel Public WithEvents Label5 As MetroFramework.Controls.MetroLabel
Friend WithEvents CheckBox2 As MetroFramework.Controls.MetroCheckBox Friend WithEvents CheckBox2 As MetroFramework.Controls.MetroCheckBox
Friend WithEvents Server As MetroFramework.Controls.MetroCheckBox
Friend WithEvents CB_fun_ptbr As MetroFramework.Controls.MetroCheckBox Friend WithEvents CB_fun_ptbr As MetroFramework.Controls.MetroCheckBox
Friend WithEvents CB_fun_es As MetroFramework.Controls.MetroCheckBox Friend WithEvents CB_fun_es As MetroFramework.Controls.MetroCheckBox
Friend WithEvents CB_fun_eng As MetroFramework.Controls.MetroCheckBox Friend WithEvents CB_fun_eng As MetroFramework.Controls.MetroCheckBox
@ -1747,4 +1750,5 @@ Partial Class Einstellungen
Friend WithEvents BackgroundWorker1 As System.ComponentModel.BackgroundWorker Friend WithEvents BackgroundWorker1 As System.ComponentModel.BackgroundWorker
Friend WithEvents DD_Episode_Prefix As MetroFramework.Controls.MetroComboBox Friend WithEvents DD_Episode_Prefix As MetroFramework.Controls.MetroComboBox
Friend WithEvents DD_Season_Prefix As MetroFramework.Controls.MetroComboBox Friend WithEvents DD_Season_Prefix As MetroFramework.Controls.MetroComboBox
Friend WithEvents http_support As MetroFramework.Controls.MetroComboBox
End Class End Class

View File

@ -7,6 +7,7 @@ Imports System.Threading
Imports MetroFramework.Forms Imports MetroFramework.Forms
Imports MetroFramework Imports MetroFramework
Imports MetroFramework.Components Imports MetroFramework.Components
Imports System.Text.RegularExpressions
Public Class Einstellungen Public Class Einstellungen
Inherits MetroForm Inherits MetroForm
@ -240,14 +241,40 @@ Public Class Einstellungen
End Try End Try
Try Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader") Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Server.Checked = CBool(Integer.Parse(rkg.GetValue("StartServer").ToString)) Dim ServerSetting As String = rkg.GetValue("ServerPort").ToString
If ServerSetting = 0 Then
http_support.Text = "add-on support disabled"
Else
http_support.Text = ServerSetting
End If
Catch ex As Exception Catch ex As Exception
End Try End Try
End Sub End Sub
Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles pictureBox4.Click Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles pictureBox4.Click
' MsgBox(Name_season.Text)
Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\CRDownloader") Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\CRDownloader")
If http_support.Text = "add-on support disabled" Then
rk.SetValue("ServerPort", 0, RegistryValueKind.String)
Main.StartServer = False
Else
Dim Port As Integer = 0
Try
Port = CInt(http_support.Text)
rk.SetValue("ServerPort", Port, RegistryValueKind.String)
Main.StartServer = False
Catch ex As Exception
MsgBox("The add-on support Port can only be numbers!", MsgBoxStyle.Exclamation)
Exit Sub
End Try
End If
' MsgBox(Name_season.Text)
If InStr(TextBox1.Text, "https://") Then If InStr(TextBox1.Text, "https://") Then
Main.Startseite = TextBox1.Text Main.Startseite = TextBox1.Text
rk.SetValue("Startseite", Main.Startseite, RegistryValueKind.String) rk.SetValue("Startseite", Main.Startseite, RegistryValueKind.String)
@ -492,17 +519,7 @@ Public Class Einstellungen
rk.SetValue("QueueMode", 0, RegistryValueKind.String) rk.SetValue("QueueMode", 0, RegistryValueKind.String)
Main.UseQueue = False Main.UseQueue = False
End If End If
If Server.Checked = True Then
rk.SetValue("StartServer", 1, RegistryValueKind.String)
Main.StartServer = True
'Dim t As New Thread(AddressOf Main.ServerStart)
't.Priority = ThreadPriority.Normal
't.IsBackground = True
't.Start()
ElseIf Server.Checked = False Then
rk.SetValue("StartServer", 0, RegistryValueKind.String)
Main.StartServer = False
End If
#Region "sof subs" #Region "sof subs"
Main.SoftSubs.Clear() Main.SoftSubs.Clear()
@ -880,10 +897,10 @@ Public Class Einstellungen
End Sub End Sub
Private Sub Server_Click(sender As Object, e As EventArgs) Handles Server.Click Private Sub Server_Click(sender As Object, e As EventArgs)
If Server.Checked = True Then 'If Server.Checked = True Then
MsgBox("This feature requires a restart of the downloader", MsgBoxStyle.Information) ' MsgBox("This feature requires a restart of the downloader", MsgBoxStyle.Information)
End If 'End If
End Sub End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
@ -948,17 +965,5 @@ Public Class Einstellungen
#End Region #End Region
End Class End Class