Reputation: 33
I've been trying to make a basic chrome extension that will search the Wayback Machine based off a link. I'm trying to set it up so that when I right-click a link, the context menu has a 'go to wayback machine' option. This is what I have:
manifest.json:
{
"name" : "Archive Right Click",
"manifest_version" : 2,
"version" : "1.0",
"description" : "Adds Go to Archive to right-click context menu.",
"icons" : {
"16" : "icon-16.png",
"48" : "icon-48.png"
},
"browser_action" : {
"default_icon": "icon-16.png",
"default_title" : "Go to Archive"
},
"permissions" : [
"tabs",
"contextMenus"
],
"background" : {
"scripts" : ["script.js"]
}
}
script.js:
function searchArchive(info,tab) {
var url = info.linkUrl;
var archiveURL = "https://web.archive.org/web/*/" + url;
chrome.tabs.create({
url : archiveURL,
});
}
chrome.contextMenus.create(
{
"context" : ["link"],
"title" : "Open link in Archive",
"onclick" : searchArchive
});
The problem is that it doesn't even show up in the context menu let alone open the tab I want.
Let me know about any useful tutorials on chrome extensions. I haven't been able to find a beginner resource that provides good examples.
Upvotes: 0
Views: 50
Reputation: 4689
You should change context
by contexts
in your script.js
function searchArchive(info,tab) {
var url = info.linkUrl;
var archiveURL = "https://web.archive.org/web/*/" + url;
chrome.tabs.create({
url : archiveURL,
});
}
chrome.contextMenus.create({
"contexts" : ["link"]
"title" : "Open link in Archive",
"onclick" : searchArchive
});
Upvotes: 1