I need to quote the name of the current icon in function, how to use JavaScript to achieve? Or if there are other way?
On the basis of the script to https://greasyfork.org/zh-CN/scripts/404859
Var iconArray=[
{
Name: 'Google',
Image: 'https://i.ibb.co/R9HMTyR/1-5.png',
Host: [' www.google.com '],
Popup: function (text, name) {
Open (' https://www.google.com/s? Wd='+ encodeURIComponent (text), name);
console.log(name);
}
},
{
Name: 'Bing'
Image: 'https://i.ibb.co/R9HMTyR/1-5.png',
Host: [' www.bing.com '],
Popup: function (text, name) {
Open (' https://www.bing.com/s? Wd='+ encodeURIComponent (text), name);
console.log(name);
}
},
]
The function open (url, a) {
Try {
If (GM_openInTab (url, {loadInBackground: true, insert: true, setParent: true})) {
If (GM_getValue (a). Times) {
GM_setValue (a, {
'times' : GM_getValue (a). The Times + 1
});
} else {
GM_setValue (a, {
1
'times' :});
}
The console. The log (' times - '+ GM_getValue (a). The Times).
} else {
}
{} the catch (error)
Return GM_openInTab (url, {loadInBackground: true, insert: true, setParent: true});
}
}
I want to store this data in grease monkey, open Google, Bing 4
{
"Google" : {
"Times" : "1",
},
"Bing" : {
"Times" : "4",
},
}