Create a folder named search_youtube_sort and add the following manifest.json and search_youtube_sort.js files to this folder.
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
browser.contextMenus.create({ | |
id: "search-youtube-relevance", | |
title: "Relevance", | |
contexts: ["selection"] | |
}); | |
browser.contextMenus.create({ | |
id: "search-youtube-upload-date", | |
title: "Upload Date", | |
contexts: ["selection"] | |
}); | |
browser.contextMenus.create({ | |
id: "search-youtube-view-count", | |
title: "View Count", | |
contexts: ["selection"] | |
}); | |
browser.contextMenus.create({ | |
id: "search-youtube-rating", | |
title: "Rating", | |
contexts: ["selection"] | |
}); | |
browser.contextMenus.onClicked.addListener(function(info, tab) { | |
if(info.menuItemId == "search-youtube-relevance"){ | |
var searchYoutube = "https://www.youtube.com/results?search_query=" + info.selectionText; | |
browser.tabs.create({url: searchYoutube}); | |
} | |
else if(info.menuItemId == "search-youtube-upload-date"){ | |
var searchYoutube = "https://www.youtube.com/results?sp=CAI%253D&search_query=" + info.selectionText; | |
browser.tabs.create({url: searchYoutube}); | |
} | |
else if(info.menuItemId == "search-youtube-view-count"){ | |
var searchYoutube = "https://www.youtube.com/results?sp=CAMSAhAB&search_query=" + info.selectionText; | |
browser.tabs.create({url: searchYoutube}); | |
} | |
else if(info.menuItemId == "search-youtube-rating"){ | |
var searchYoutube = "https://www.youtube.com/results?sp=CAESAhAB&search_query=" + info.selectionText; | |
browser.tabs.create({url: searchYoutube}); | |
} | |
}); |
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
{ | |
"manifest_version": 2, | |
"name": "Search Youtube", | |
"version": "1.0", | |
"description": "Searches Youtube for the Selected Text with Specified Sort Criteria.", | |
"permissions": ["contextMenus", "activeTab"], | |
"background": { | |
"scripts": ["search_youtube_sort.js"] | |
} | |
} |
No comments:
Post a Comment