@@ -3,40 +3,38 @@ function convertShortsUrl(url: string) {
33 return url . replace ( regex , '/watch?v=$1' )
44}
55
6- chrome . runtime . onInstalled . addListener ( function ( ) {
7- chrome . contextMenus . create ( {
8- title : 'No More Shorts' ,
9- contexts : [ 'all' ] ,
10- id : 'no-more-shorts' ,
11- documentUrlPatterns : [
12- 'https://*.youtube.com/shorts/*' ,
13- 'http://*.youtube.com/shorts/*' ,
14- ] ,
6+ chrome . contextMenus . create ( {
7+ title : 'No More Shorts' ,
8+ contexts : [ 'all' ] ,
9+ id : 'no-more-shorts' ,
10+ documentUrlPatterns : [
11+ 'https://*.youtube.com/shorts/*' ,
12+ 'http://*.youtube.com/shorts/*' ,
13+ ] ,
14+ } )
15+
16+ // on context menu click
17+ chrome . contextMenus . onClicked . addListener ( async ( ) => {
18+ const [ { url } ] = await chrome . tabs . query ( {
19+ active : true ,
20+ currentWindow : true ,
1521 } )
22+ const newUrl = convertShortsUrl ( url ! )
1623
17- // on context menu click
18- chrome . contextMenus . onClicked . addListener ( async ( ) => {
19- const [ { url } ] = await chrome . tabs . query ( {
20- active : true ,
21- currentWindow : true ,
22- } )
23- const newUrl = convertShortsUrl ( url ! )
24+ chrome . tabs . update ( {
25+ url : newUrl ,
26+ } )
27+ } )
2428
29+ // on page load
30+ chrome . webRequest . onCompleted . addListener (
31+ ( { url } ) => {
32+ const newUrl = convertShortsUrl ( url ! )
2533 chrome . tabs . update ( {
2634 url : newUrl ,
2735 } )
28- } )
29-
30- // on page load
31- chrome . webRequest . onCompleted . addListener (
32- ( { url } ) => {
33- const newUrl = convertShortsUrl ( url ! )
34- chrome . tabs . update ( {
35- url : newUrl ,
36- } )
37- } ,
38- {
39- urls : [ 'https://*.youtube.com/shorts/*' , 'http://*.youtube.com/shorts/*' ] ,
40- }
41- )
42- } )
36+ } ,
37+ {
38+ urls : [ 'https://*.youtube.com/shorts/*' , 'http://*.youtube.com/shorts/*' ] ,
39+ }
40+ )
0 commit comments