File tree 4 files changed +43
-1
lines changed 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1439
1439
},
1440
1440
"pauseWhileIAmTypingOnYouTube" : {
1441
1441
"message" : " Pause when I'm typing on YouTube"
1442
+ },
1443
+ "clickableLinksInDescription" : {
1444
+ "message" : " Right click to copy links in video descriptions"
1442
1445
}
1443
1446
}
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ function bodyReady () {
28
28
if ( extension . ready && extension . domReady ) {
29
29
extension . features . addScrollToTop ( ) ;
30
30
extension . features . font ( ) ;
31
+ extension . features . clickableLinksInVideoDescriptions ( ) ;
31
32
}
32
33
}
33
34
@@ -44,7 +45,7 @@ extension.events.on('init', function () {
44
45
extension . features . relatedVideos ( ) ;
45
46
extension . features . comments ( ) ;
46
47
extension . features . openNewTab ( ) ;
47
- extension . features . removeListParamOnNewTab ( ) ;
48
+ extension . features . removeListParamOnNewTab ( ) ;
48
49
bodyReady ( ) ;
49
50
} ) ;
50
51
Original file line number Diff line number Diff line change @@ -616,3 +616,37 @@ extension.features.removeListParamOnNewTab = function () {
616
616
} ;
617
617
618
618
extension . features . removeListParamOnNewTab ( ) ;
619
+
620
+ /*--------------------------------------------------------------
621
+ # CLICKABLE LINKS IN VIDEO DESCRIPTIONS
622
+ --------------------------------------------------------------*/
623
+ extension . features . clickableLinksInVideoDescriptions = function ( ) {
624
+ if ( extension . storage . get ( "clickable_links_in_description" ) !== true ) {
625
+ return ;
626
+ }
627
+
628
+ document . addEventListener ( "contextmenu" , ( e ) => {
629
+ // Check if the clicked element is a yt-formatted-string with the class we're targeting
630
+ const clickedElement = e . target . closest ( ".style-scope.ytd-video-renderer" ) ;
631
+
632
+ if ( clickedElement ) {
633
+ // Grab the plain text inside the yt-formatted-string (looking for links or URLs)
634
+ const textContent = clickedElement . innerText ;
635
+
636
+ // Extract URL using a simple regex (you can customize it to be more accurate)
637
+ const urlRegex = / \b h t t p s ? : \/ \/ [ ^ \s ] + / g;
638
+ const match = textContent . match ( urlRegex ) ;
639
+
640
+ if ( match ) {
641
+ // Copy the found URL to the clipboard
642
+ navigator . clipboard . writeText ( match [ 0 ] ) . catch ( ( err ) => {
643
+ console . error ( "Failed to copy: " , err ) ;
644
+ } ) ;
645
+
646
+ // Prevent the default right-click menu from showing
647
+ e . preventDefault ( ) ;
648
+ }
649
+ // If no URL found, the normal right-click behavior will happen
650
+ }
651
+ } ) ;
652
+ }
Original file line number Diff line number Diff line change @@ -408,6 +408,10 @@ extension.skeleton.main.layers.section.general = {
408
408
remove_list_param_from_links : {
409
409
component : 'switch' ,
410
410
text : 'removePlaylistParam'
411
+ } ,
412
+ clickable_links_in_description : {
413
+ component : 'switch' ,
414
+ text : 'clickableLinksInDescription'
411
415
}
412
416
}
413
417
}
You can’t perform that action at this time.
0 commit comments