-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Recommend Aria2 Manager if start Aria2 failed
- Loading branch information
Showing
9 changed files
with
94 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Start Aria2</title> | ||
<script src="js/startAria2.js" type="module"></script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const SCHEME_ARIA2_START = "aria2://start/"; | ||
const PROMOTION_PAGE = chrome.runtime.getURL('ui/ariang/index.html') + "#!recommend?path=/posts/3#usage"; | ||
|
||
var focused = true; | ||
var confirmed = false; | ||
|
||
window.addEventListener('blur', function () { | ||
focused = false; | ||
console.log('Web page is blurred'); | ||
chrome.runtime.sendMessage({ type: 'QUERY_WINDOW_STATE', data: chrome.windows.WINDOW_ID_CURRENT }).then( | ||
(response) => { | ||
if (response && response.data) { | ||
let currentWindow = response.data; | ||
console.log('Current window = %d, focus =', currentWindow.id, currentWindow.focused); | ||
if (!currentWindow.focused) { | ||
console.log('Chrome is blurred, Web page will close.'); | ||
window.close(); | ||
} | ||
} | ||
} | ||
) | ||
}); | ||
|
||
window.addEventListener('focus', function () { | ||
focused = true; | ||
console.log('Web page is focused, if not confirmed, it will close. confirmed = ', confirmed); | ||
!confirmed && window.close(); | ||
}); | ||
|
||
window.location.href = SCHEME_ARIA2_START; | ||
|
||
setTimeout(() => { | ||
if (focused) { | ||
let des = chrome.i18n.getMessage("Aria2ManagerPromotionDes"); | ||
if (confirm(des)) { | ||
confirmed = true; | ||
window.location.href = PROMOTION_PAGE; | ||
} else { | ||
console.log('Promotion is canceled, web page will close.') | ||
window.close(); | ||
} | ||
} | ||
}, 300); | ||
|