File tree Expand file tree Collapse file tree 5 files changed +51
-14
lines changed
Expand file tree Collapse file tree 5 files changed +51
-14
lines changed Original file line number Diff line number Diff line change 11{
2- "manifest_version" : 2 ,
2+ "manifest_version" : 3 ,
33
44 "name" : " Feedly Notifier" ,
55 "description" : " __MSG_ExtensionDescription__" ,
99 " storage" ,
1010 " tabs" ,
1111 " notifications" ,
12- " webRequest" ,
12+ " webRequest"
13+ ],
14+ "host_permissions" : [
1315 " *://*.feedly.com/"
1416 ],
15- "optional_permissions" : [
16- // @if BROWSER='chrome'
17- " background" ,
18- // @endif
17+ "optional_host_permissions" : [
1918 " <all_urls>"
2019 ],
21- "browser_action " : {
20+ "action " : {
2221 "default_icon" : {
2322 "19" : " /images/icon_inactive.png" ,
2423 "38" : " /images/icon_inactive38.png"
4544 },
4645 // @endif
4746 "background" : {
48- "scripts " : [ " scripts/browser-polyfill.min. js" , " scripts/feedly.api.js " , " scripts/core.js " ]
47+ "service_worker " : " scripts/background. js"
4948 },
5049 "icons" : {
5150 "16" : " /images/icon16.png" ,
5251 "48" : " /images/icon48.png" ,
5352 "128" : " /images/icon128.png"
5453 },
55- "web_accessible_resources" : [
56- " /images/icon128.png"
57- ],
54+ "web_accessible_resources" : [{
55+ "resources" : [" /images/icon128.png" , " sound/*.mp3" ],
56+ "matches" : [" <all_urls>" ]
57+ }],
5858 // @if BROWSER!='firefox'
5959 "minimum_chrome_version" : " 70" ,
6060 // @endif
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 " />
5+ </ head >
6+ < body >
7+ < script src ="scripts/offscreen.js "> </ script >
8+ </ body >
9+ </ html >
Original file line number Diff line number Diff line change 1+ importScripts ( 'browser-polyfill.min.js' , 'feedly.api.js' , 'core.js' ) ;
2+
3+ async function ensureOffscreen ( ) {
4+ if ( chrome . offscreen && ! ( await chrome . offscreen . hasDocument ( ) ) ) {
5+ await chrome . offscreen . createDocument ( {
6+ url : 'offscreen.html' ,
7+ reasons : [ chrome . offscreen . Reason . AUDIO_PLAYBACK ] ,
8+ justification : 'play notification sounds'
9+ } ) ;
10+ }
11+ }
12+
13+ chrome . runtime . onMessage . addListener ( ( msg , sender , sendResponse ) => {
14+ if ( msg && msg . type === 'playSound' ) {
15+ ensureOffscreen ( ) . then ( ( ) => {
16+ chrome . runtime . sendMessage ( { offscreen : 'playSound' , url : msg . url , volume : msg . volume } ) ;
17+ } ) ;
18+ }
19+ } ) ;
Original file line number Diff line number Diff line change @@ -387,9 +387,11 @@ function removeFeedFromCache(feedId) {
387387
388388/* Plays alert sound */
389389function playSound ( ) {
390- var audio = new Audio ( appGlobal . options . sound ) ;
391- audio . volume = appGlobal . options . soundVolume ;
392- audio . play ( ) ;
390+ chrome . runtime . sendMessage ( {
391+ type : 'playSound' ,
392+ url : chrome . runtime . getURL ( appGlobal . options . sound ) ,
393+ volume : appGlobal . options . soundVolume
394+ } ) ;
393395}
394396
395397/* Returns only new feeds and set date of last feed
Original file line number Diff line number Diff line change 1+ chrome . runtime . onMessage . addListener ( ( msg ) => {
2+ if ( msg && msg . offscreen === 'playSound' ) {
3+ const audio = new Audio ( msg . url ) ;
4+ audio . volume = msg . volume ?? 1 ;
5+ audio . play ( ) ;
6+ }
7+ } ) ;
You can’t perform that action at this time.
0 commit comments