-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontextmenu.js
38 lines (36 loc) · 1017 Bytes
/
contextmenu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function handler(from, to) {
return function(info, tab) {
var funcname = from.toLowerCase() + '2' + to.toLowerCase();
chrome.tabs.executeScript(tab.id, {
file: "jquery-1.9.1.min.js"
});
chrome.tabs.executeScript(tab.id, {
file: "wikitextconverter.js"
});
chrome.tabs.executeScript(tab.id, {
code: "var funcname = '" + funcname + "'"
});
chrome.tabs.executeScript(tab.id, {
file: "convert.js"
});
console.log(funcname);
}
}
var transes = [
[ "Hatenak", "Textile" ],
[ "Textile", "Hatenak" ],
[ "Hatenak", "Markdown" ],
[ "Markdown", "Hatenak" ],
[ "Textile", "Markdown" ],
[ "Markdown", "Textile" ],
]
transes.forEach(function(trans) {
var from = trans[0];
var to = trans[1];
var title = from + " => " + to;
chrome.contextMenus.create({
title: title,
contexts: ["editable"],
onclick: handler(from, to)
});
});