add-on improvments

-chrome add-on fully functional
-add-on status added
This commit is contained in:
hama3254 2020-10-15 13:49:06 +02:00
parent e60637c66c
commit 1c309ef781
15 changed files with 120 additions and 79 deletions

Binary file not shown.

View File

@ -15,26 +15,27 @@ chrome.tabs.query({
chrome.tabs.executeScript(null, { chrome.tabs.executeScript(null, {
//code: 'document.getElementsByClassName("episode")[0].href;' //code: 'document.getElementsByClassName("episode")[0].href;'
code: 'document.getElementsByClassName("episode").length;' code: 'document.getElementsByClassName("episode").length;'
}, },
function (results) { function (results) {
if (results > 0 ) if (results > 0) {
{
onExecuted(results); onExecuted(results);
} else { } else {
onError("error") onError("error")
} }
}); });
} else if (tab.url.includes('funimation.com')) { } else if (tab.url.includes('funimation.com')) {
chrome.tabs.executeScript(null, { chrome.tabs.executeScript(null, {
code: 'document.getElementsByClassName("trackVideo")[0].href' //code: 'document.getElementsByClassName("trackVideo")[0].href'
code: 'document.getElementsByClassName("trackVideo").length;'
}, },
function (results) { function (results) {
if (results !== null) { if (results > 0) {
FunimationSuccess(results); FunimationSuccess(results);
} else { } else {
@ -152,10 +153,10 @@ document.getElementById('btn_add').addEventListener('click', () => {
setTimeout(function () { setTimeout(function () {
document.getElementById("btn_add").style.background = "#ff8000" document.getElementById("btn_add").style.background = "#ff8000"
}, 4000); }, 10000);
setTimeout(function () { setTimeout(function () {
document.getElementById("btn_add").disabled = false; document.getElementById("btn_add").disabled = false;
}, 4000); }, 10000);
} else { } else {
add_one_error(results); add_one_error(results);
@ -173,7 +174,10 @@ document.getElementById('btn_add_funimation').addEventListener('click', () => {
currentWindow: true currentWindow: true
}, },
function (tabs) { function (tabs) {
console.log(tabs.length); document.getElementById("btn_add_funimation").disabled = true;
document.getElementById("btn_add_funimation").style.background = "#c9c9c9"
console.log(tabs.length);
let tab = tabs[0]; // Safe to assume there will only be one resultconsole.log(tab.url); let tab = tabs[0]; // Safe to assume there will only be one resultconsole.log(tab.url);
console.log(tab.url); console.log(tab.url);
const form = document.createElement('form'); const form = document.createElement('form');
@ -188,6 +192,12 @@ document.getElementById('btn_add_funimation').addEventListener('click', () => {
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();
setTimeout(function () {
document.getElementById("btn_add_funimation").style.background = "#ff8000"
}, 10000);
setTimeout(function () {
document.getElementById("btn_add_funimation").disabled = false;
}, 10000);
}); });
}); });
@ -231,28 +241,32 @@ document.getElementById('btn_add_mass').addEventListener('click', () => {
}); });
function onExecuted(result) { function onExecuted(result) {
console.log(result[0]); chrome.tabs.executeScript(null, {
code: "document.getElementsByClassName('episode')[0].href.includes('javascript:');"
},
function (result) {
//alert(result);
if (result == 'true') {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_add_mass").hidden = false;
document.getElementById("btn_select_all").hidden = false;
document.getElementById("btn_select_none").hidden = false;
document.getElementById("btn_enable_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
console.log(true);
} else {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_enable_select").hidden = false;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
console.log(false);
}
});
if (result[0].includes('javascript:')) {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_add_mass").hidden = false;
document.getElementById("btn_select_all").hidden = false;
document.getElementById("btn_select_none").hidden = false;
document.getElementById("btn_enable_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
console.log(true);
} else {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_enable_select").hidden = false;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
console.log(false);
}
} }
function onError(error) { function onError(error) {
@ -296,29 +310,32 @@ document.getElementById('btn_enable_funimation_select').addEventListener('click'
}); });
function FunimationSuccess(result) { function FunimationSuccess(result) {
console.log(result[0]); chrome.tabs.executeScript(null, {
code: "document.getElementsByClassName('trackVideo')[0].href.includes('javascript:');"
},
function (result) {
if (result == 'true') {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_add_mass").hidden = false;
document.getElementById("btn_select_all").hidden = false;
document.getElementById("btn_select_none").hidden = false;
document.getElementById("btn_enable_select").hidden = true;
if (result[0].includes('javascript:')) { document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add").hidden = true; document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_mass").hidden = false; console.log(true);
document.getElementById("btn_select_all").hidden = false; } else {
document.getElementById("btn_select_none").hidden = false; document.getElementById("btn_add").hidden = true;
document.getElementById("btn_enable_select").hidden = true; document.getElementById("btn_add_funimation").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 = false;
document.getElementById("btn_enable_funimation_select").hidden = true; console.log(false);
document.getElementById("btn_add_funimation").hidden = true; }
console.log(true); });
} else {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_add_funimation").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 = false;
console.log(false);
}
} }
function FunimationError(error) { function FunimationError(error) {

View File

@ -182,6 +182,7 @@ Public Class GeckoFX
t.Start() t.Start()
Else Else
Main.StatusMainForm.Text = "Status: no video found"
Anime_Add.StatusLabel.Text = "fail?" Anime_Add.StatusLabel.Text = "fail?"
End If End If
End If End If

View File

@ -1398,6 +1398,12 @@ Public Class Main
Dim Pfad5 As String = Pfad2.Replace(Chr(34), "") Dim Pfad5 As String = Pfad2.Replace(Chr(34), "")
If My.Computer.FileSystem.FileExists(Pfad5) Then 'Pfad = Kompeltter Pfad mit Dateinamen + ENdung If My.Computer.FileSystem.FileExists(Pfad5) Then 'Pfad = Kompeltter Pfad mit Dateinamen + ENdung
Me.Invoke(New Action(Function()
Anime_Add.StatusLabel.Text = "Status: The file video already exists."
StatusMainForm.Text = "Status: The file video already exists."
Return Nothing
End Function))
If MessageBox.Show("The file " + Pfad5 + " already exists." + vbNewLine + "You want to override it?", "File exists!", MessageBoxButtons.OKCancel) = DialogResult.OK Then If MessageBox.Show("The file " + Pfad5 + " already exists." + vbNewLine + "You want to override it?", "File exists!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
Try Try
My.Computer.FileSystem.DeleteFile(Pfad5) My.Computer.FileSystem.DeleteFile(Pfad5)
@ -2583,10 +2589,7 @@ Public Class Main
If InStr(htmlReq, "HTMLSingle=") Then If InStr(htmlReq, "HTMLSingle=") Then
Debug.WriteLine("Single episode mode - Crunchyroll") Debug.WriteLine("Single episode mode - Crunchyroll")
Me.Invoke(New Action(Function()
StatusMainForm.Text = "Status: Download added from plugin"
Return Nothing
End Function))
Try Try
Dim html() As String = htmlReq.Split(New String() {"HTMLSingle="}, System.StringSplitOptions.RemoveEmptyEntries) Dim html() As String = htmlReq.Split(New String() {"HTMLSingle="}, System.StringSplitOptions.RemoveEmptyEntries)
Dim DecodedHTML As String = UrlDecode(html(1)) Dim DecodedHTML As String = UrlDecode(html(1))
@ -2598,25 +2601,41 @@ Public Class Main
Dim TitleSplit() As String = DecodedHTML.Split(New String() {"<title>"}, System.StringSplitOptions.RemoveEmptyEntries) Dim TitleSplit() As String = DecodedHTML.Split(New String() {"<title>"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim TitleSplit2() As String = TitleSplit(1).Split(New String() {"</title>"}, System.StringSplitOptions.RemoveEmptyEntries) Dim TitleSplit2() As String = TitleSplit(1).Split(New String() {"</title>"}, System.StringSplitOptions.RemoveEmptyEntries)
WebbrowserTitle = TitleSplit2(0) WebbrowserTitle = TitleSplit2(0)
If Grapp_RDY = True Then If CBool(InStr(WebbrowserText, "hardsub_lang")) Then
Dim t As Thread Me.Invoke(New Action(Function()
t = New Thread(AddressOf GrappURL) StatusMainForm.Text = "Status: Download added from add-on"
t.Priority = ThreadPriority.Normal Return Nothing
t.IsBackground = True End Function))
t.Start() If Grapp_RDY = True Then
Else Dim t As Thread
If Application.OpenForms().OfType(Of Anime_Add).Any = True Then t = New Thread(AddressOf GrappURL)
Me.Invoke(New Action(Function() t.Priority = ThreadPriority.Normal
Anime_Add.ListBox1.Items.Add(WebbrowserURL) t.IsBackground = True
Return Nothing t.Start()
End Function))
Else Else
ListBoxList.Add(WebbrowserURL) If Application.OpenForms().OfType(Of Anime_Add).Any = True Then
Me.Invoke(New Action(Function()
Anime_Add.ListBox1.Items.Add(WebbrowserURL)
Return Nothing
End Function))
Else
ListBoxList.Add(WebbrowserURL)
End If
End If End If
strRequest = rootPath & "Post_Single_Sucess.html" 'PostPage
sendHTMLResponse(strRequest, clientSocket)
Else
Me.Invoke(New Action(Function()
StatusMainForm.Text = "Status: no video found"
Return Nothing
End Function))
Dim ErrorPage As String = My.Resources.Post_error_Top + "no video found" + My.Resources.Post_error_Bottom
My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\WebInterface\error_Page.html", ErrorPage, False)
strRequest = rootPath & "error_Page.html" 'PostPage
sendHTMLResponse(strRequest, clientSocket)
End If End If
strRequest = rootPath & "Post_Single_Sucess.html" 'PostPage
sendHTMLResponse(strRequest, clientSocket)
Catch ex As Exception Catch ex As Exception
Dim ErrorPage As String = My.Resources.Post_error_Top + ex.ToString + My.Resources.Post_error_Bottom Dim ErrorPage As String = My.Resources.Post_error_Top + ex.ToString + My.Resources.Post_error_Bottom
My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\WebInterface\error_Page.html", ErrorPage, False) My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\WebInterface\error_Page.html", ErrorPage, False)
@ -2666,7 +2685,7 @@ Public Class Main
Debug.WriteLine("single episode mode - Funimation") Debug.WriteLine("single episode mode - Funimation")
'Debug.WriteLine(htmlReq) 'Debug.WriteLine(htmlReq)
Me.Invoke(New Action(Function() Me.Invoke(New Action(Function()
StatusMainForm.Text = "Status: Download added from plugin" StatusMainForm.Text = "Status: Download added from add-on"
Return Nothing Return Nothing
End Function)) End Function))
Try Try
@ -2694,6 +2713,10 @@ Public Class Main
Else Else
ListBoxList.Add(WebbrowserURL) ListBoxList.Add(WebbrowserURL)
Me.Invoke(New Action(Function()
StatusMainForm.Text = "Status: " + ListBoxList.Count.ToString + " Downloads in queue"
Return Nothing
End Function))
End If End If
End If End If
strRequest = rootPath & "Post_Single_Sucess.html" 'PostPage strRequest = rootPath & "Post_Single_Sucess.html" 'PostPage

View File

@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.5.3")> <Assembly: AssemblyVersion("3.5.4")>
<Assembly: AssemblyFileVersion("3.5.3")> <Assembly: AssemblyFileVersion("3.5.4")>
<Assembly: NeutralResourcesLanguage("en")> <Assembly: NeutralResourcesLanguage("en")>

View File

@ -1,6 +1,6 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
</head> </head>
<style> <style>
body { body {
@ -42,7 +42,7 @@
<i class="checkmark"></i> <i class="checkmark"></i>
</div> </div>
<h1>Failed!</h1> <h1>Failed!</h1>
<p></p> <p>no video found</p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -27,7 +27,7 @@
.liClass{margin-bottom:8px} .liClass{margin-bottom:8px}
</style> </style>
<body id="bodypage" class="main-bg" > <body id="bodypage" class="main-bg" >
<a class="main_titel">Crunchyroll Downloader</a> <a class="main_titel">Status: no video found</a>
<img alt="image error" src="balken.png" class="class-balken"> <img alt="image error" src="balken.png" class="class-balken">
<script> <script>