Chrome 扩展清单版本:2 xml
Posted
技术标签:
【中文标题】Chrome 扩展清单版本:2 xml【英文标题】:Chrome extension manifest version:2 xml 【发布时间】:2012-08-02 05:39:02 【问题描述】:我正在使用 javascript rss 搜索脚本作为可搜索的工作电话/地址列表。我将它作为带有清单版本:1 的工具栏上的 Chrome 弹出扩展程序,但我无法让它与版本:2 一起使用。在版本:1 中,xml 数据库文件不需要在清单中命名,但似乎在版本:2 中确实如此,但对于我的生活,我无法弄清楚它应该去哪里。我不希望它被上传到服务器或任何东西,因为我们只需要它在本地工作,它在 version:1 上做得很好。
我尝试搜索要复制的清单文件,但大多数答案都引用了较旧的清单版本,例如Chrome Extension Manifest 'Matches'
我希望我错过了一些简单的东西,所以如果有人可以提供帮助,将不胜感激。
这是我的清单代码:
修改后的代码如下:
"name": "Telephone Search",
"version": "2.0",
"description": "Tel Test.",
"browser_action":
"default_icon": "icon.png",
"default_title": "Addresses",
"default_popup": "index.html"
,
"content_scripts": [
"matches": [
"http://*/*",
"file://*/*",
"<all_urls>"
],
"js": [
"combinedTipue.js"
]
],
"permissions": [
"tabs",
"http://*/*",
"file://*/*",
"<all_urls>"
],
"manifest_version": 2
xml 文件tipue_data.xml 位于我一直试图让它工作的几个地方!!
@罗伯·W 如果您的意思是 .js 脚本,我在下面添加了它们: (很抱歉,如果它们应该放在“cmets”而不是“answers”中,但有字符限制)
tipue.js
combineTipue.js
function setFocus()
document.getElementById("searchBox").focus();
// Tipue JS 4.2
//
// Tipue JS Copyright (C) 2002-2007 Tri-State Consultants
// Tipue JS is open source and released under the GNU General Public License
// Start tipue_set code
// Tipue JS 4.2
//
// Tipue JS Copyright (C) 2002-2007 Tri-State Consultants
// Tipue JS is open source and released under the GNU General Public License
//
// Tipue JS Set
// General
data = 'tipue_data.xml';
data_source = 1;
results_location = 'results.html';
// Results
per_page = 10;
context = 1;
context_seed = 100;
descriptive_length = 25;
rank_seed = 3;
include_num = 0;
include_url = 1;
header_links = 1;
bold_query = 1;
bold_title = 1;
bold_footer = 1;
// Search
common_words = 'a about an are as at be by do for from how I in is it of on that the this to was what when where who will with';
stemming = 'javascript^js checkboxes^checkbox';
spell = 'tipu^Tipue endshet^Endsheet';
// Text
tl_1 = 'Your search - ';
tl_2 = ' - did not match any documents.<p>Suggestions:<p>Make sure all keywords are spelled correctly.<br>Try different or more general keywords.';
tl_3 = 'Previous';
tl_4 = 'Next';
tl_5 = 'to';
tl_6 = 'of';
tl_7 = 'for';
tl_8 = 'Did you mean:';
tl_9 = 'The following common words have been excluded from your search:';
tl_10 = 'Blank search.';
tl_11 = '<p>Powered by <a href="http://www.tipue.com" target="_blank">Tipue</a>';
tl_12 = 'Results';
// XML
xml_pages = 'page';
xml_title = 'title';
xml_url = 'url';
xml_content = 'content';
// End tipue_set code
tid = window.location.search;
rd = tid.indexOf('?d=');
rn = tid.indexOf('&n=');
if (rn == -1)
dit = tid.substring(rd + 3);
tn = 0;
else
dit = tid.substring(rd + 3, rn);
tn = parseInt(tid.substring(rn + 3));
dit = dit.replace(/\+/g, ' ');
dit = decodeURIComponent(dit);
dit = dit.replace(/\s+/g, ' ');
od = dit;
hd = dit;
dit = dit.replace(/ and /gi, ' ');
dit = dit.replace(/- /gi, '-');
dit = dit.replace(/\s+/g, ' ');
nr = per_page;
r_l = results_location;
b_q = bold_query;
b_t = bold_title;
b_f = bold_footer;
ct = context;
c_s = context_seed;
seed = rank_seed;
ct_l = descriptive_length;
c_w = common_words;
tr = new Array();
co = 0;
nd = 0;
nc = 0;
sp_l = '';
cw_l = '';
if (data_source < 2)
s = new Array();
if (window.ActiveXObject)
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = false;
xmldoc.onreadystatechange = function ()
if (xmldoc.readyState == 4) get_xml();
xmldoc.load(data);
else if (window.XMLHttpRequest)
client = new XMLHttpRequest();
client.open("GET", data, false);
client.send(null);
xmldoc = client.responseXML;
get_xml();
function get_xml()
if (document.implementation && document.implementation.createDocument) xmldoc.normalize();
if (data_source == 0)
pages = xmldoc.getElementsByTagName("item");
for (c = 0; c < pages.length; c++)
rs = pages[c];
es_0 = rs.getElementsByTagName("title")[0].firstChild.data;
es_0 = es_0.replace(/\^|\~/g, '');
es_1 = rs.getElementsByTagName("link")[0].firstChild.data;
es_1 = es_1.replace(/\^|\~/g, '');
es_2 = rs.getElementsByTagName("description")[0].firstChild.data;
es_2 = es_2.replace(/\^|\~/g, '');
s[c] = es_0 + '^' + es_1 + '^' + es_2 + '^0^0';
if (data_source == 1)
pages = xmldoc.getElementsByTagName(xml_pages);
for (c = 0; c < pages.length; c++)
rs = pages[c];
es_0 = rs.getElementsByTagName(xml_title)[0].firstChild.data;
es_0 = es_0.replace(/\^|\~/g, '');
es_1 = rs.getElementsByTagName(xml_url)[0].firstChild.data;
es_1 = es_1.replace(/\^|\~/g, '');
es_2 = rs.getElementsByTagName(xml_content)[0].firstChild.data;
es_2 = es_2.replace(/\^|\~/g, '');
if (rs.getElementsByTagName("open").length > 0) es_3 = rs.getElementsByTagName("open")[0].firstChild.data;
else es_3 = '0';
if (rs.getElementsByTagName("rank").length > 0) es_4 = rs.getElementsByTagName("rank")[0].firstChild.data;
else es_4 = '0';
s[c] = es_0 + '^' + es_1 + '^' + es_2 + '^' + es_3 + '^' + es_4;
dit = dit.replace(/\^/g, '');
dit = dit.replace(/^\s+/, '');
dit = dit.replace(/\s+$/, '');
if (seed < 1) seed = 1;
if (seed > 9) seed = 10;
v_d = false;
if (dit == '' || dit == ' ') v_d = true;
t_m = 0;
if (dit.charAt(0) == '"' && dit.charAt(dit.length - 1) == '"') t_m = 1;
if (t_m == 0 && !v_d)
if (c_w.length > 0)
cw = c_w.split(' ');
for (i = 0; i < cw.length; i++)
pat = new RegExp("\\b" + cw[i] + "\\b", 'gi');
rn = dit.search(pat);
if (rn != -1)
pat_1 = new RegExp("\\+" + cw[i] + "\\b", 'gi');
pat_2 = new RegExp("\\-" + cw[i] + "\\b", 'gi');
rn_1 = dit.search(pat_1);
rn_2 = dit.search(pat_2);
if (rn_1 == -1 && rn_2 == -1)
cw_l += '<b>' + cw[i] + '</b>, ';
dit = dit.replace(pat, '');
if (cw_l.length > 0)
cw_l = cw_l.replace(/\s+$/, '');
if (cw_l.charAt(cw_l.length - 1) == ',') cw_l = cw_l.substr(0, cw_l.length - 1);
dit = dit.replace(/\s+/g, ' ');
dit = dit.replace(/^\s+/, '');
dit = dit.replace(/\s+$/, '');
if (dit == '' || dit == ' ') v_d = true;
hd = dit;
if (spell.length > 0)
cw = spell.split(' ');
for (i = 0; i < cw.length; i++)
wt = cw[i].split('^');
pat = new RegExp("\\b" + wt[0] + "\\b", 'i');
rn = dit.search(pat);
if (rn != -1)
if (sp_l.length < 1) sp_l = dit;
pat = new RegExp(wt[0], 'i');
sp_l = sp_l.replace(pat, wt[1]);
if (stemming.length > 0)
cw = stemming.split(' ');
for (i = 0; i < cw.length; i++)
wt = cw[i].split('^');
pat = new RegExp("\\b" + wt[0] + "\\b", 'i');
rn = dit.search(pat);
if (rn != -1)
dit = dit.replace(pat, wt[0] + '~' + wt[1]);
dit = dit.replace(/ or /gi, '~');
dit = dit.replace(/\"/gi, '');
ct_d = 0;
w_in = new Array();
wt = dit.split(' ');
for (i = 0; i < wt.length; i++)
w_in[i] = 0;
if (wt[i].charAt(0) == '-') w_in[i] = 1;
pat = new RegExp("\\~", 'i');
rn = wt[i].search(pat);
if (rn != -1) w_in[i] = 2;
wt[i] = wt[i].replace(/^\-|^\+/gi, '');
a = 0;
for (c = 0; c < s.length; c++)
es = s[c].split('^');
rk = 1000;
if (es[3] == null) es[3] = '0';
if (es[4] == null) es[4] = '0';
if (parseInt(es[4]) > 10) es[4] = '10';
pa = 0;
nh = 0;
for (i = 0; i < w_in.length; i++)
if (w_in[i] == 0)
nh++;
nt = 0;
pat = new RegExp("\\b" + wt[i] + "\\b", 'i');
rn = es[0].search(pat);
if (rn != -1)
rk -= seed * 3;
rk -= parseInt(es[4]);
nt = 1;
if (ct == 1) ct_d = 1;
rn = es[2].search(pat);
if (rn != -1)
rk -= seed;
rk -= parseInt(es[4]);
nt = 1;
if (nt == 1) pa++;
if (w_in[i] == 1)
pat = new RegExp("\\b" + wt[i] + "\\b", 'i');
rn = es[0].search(pat);
if (rn != -1) pa = 0;
rn = es[2].search(pat);
if (rn != -1) pa = 0;
if (w_in[i] == 2)
nh++;
nt = 0;
w_o = wt[i].split('~');
pat = new RegExp("\\b" + w_o[0] + "\\b", 'i');
pat_2 = new RegExp("\\b" + w_o[1] + "\\b", 'i');
rn = es[0].search(pat);
rn_2 = es[0].search(pat_2);
if (rn != -1 || rn_2 != -1)
rk -= seed / 2;
rk -= parseInt(es[4]);
nt = 1;
if (ct == 1) ct_d = 1;
rn = es[2].search(pat);
rn_2 = es[2].search(pat_2);
if (rn != -1 || rn_2 != -1)
rk -= seed / 2;
rk -= parseInt(es[4]);
nt = 1;
if (nt == 1) pa++;
if (pa == nh && nh != 0)
es_c = '';
ci_e = es[2].split(' ');
if (ci_e.length < ct_l)
es_c = es[2];
else
for (i = 0; i < ct_l; i++)
es_c += ci_e[i] + ' ';
es_c = es_c.replace(/^\s*|\s*$/g, '');
if (es_c.charAt(es_c.length - 1) == '.' || es_c.charAt(es_c.length - 1) == ',') es_c = es_c.substr(0, es_c.length - 1);
es_c += ' ...';
if (ct == 1 && ct_d == 0)
ct_f = true;
pat = new RegExp("\\b" + wt[0] + "\\b", 'i');
rn = es[2].search(pat);
if (rn > c_s)
t_1 = es[2].substr(rn - (c_s - 1));
rn = t_1.indexOf('. ');
if (rn != -1 && rn < (c_s / 2))
t_1 = t_1.substr(rn + 1);
t_2 = t_1.split(' ');
if (t_2.length > ct_l)
es_c = '';
for (i = 1; i < ct_l + 1; i++)
es_c += ' ' + t_2[i];
if (es_c.charAt(es_c.length - 1) == '.' || es_c.charAt(es_c.length - 1) == ',') es_c = es_c.substr(0, es_c.length - 1);
es_c += ' ...';
ct_f = false;
if (ct_f)
rn = es[2].search(pat);
t_1 = es[2].substr(rn - (c_s / 5));
rn = t_1.indexOf(' ');
if (rn != -1)
t_1 = t_1.substr(rn + 1);
t_2 = t_1.split(' ');
es_c = '';
if (t_2.length > ct_l)
for (i = 1; i < ct_l + 1; i++)
es_c += ' ' + t_2[i];
else
for (i = 1; i < t_2.length; i++)
es_c += ' ' + t_2[i];
if (es_c.charAt(es_c.length - 1) == '.' || es_c.charAt(es_c.length - 1) == ',') es_c = es_c.substr(0, es_c.length - 1);
es_c += ' ...';
tr[a] = rk + '^' + es[0] + '^' + es[1] + '^' + es_c + '^' + es[2] + '^' + es[3] + '^' + es[4];
a++;
tr.sort();
co = a;
if (t_m == 1 && !v_d)
dit = dit.replace(/"/gi, '');
a = 0;
ct_d = 0;
pat = new RegExp(dit, 'i');
for (c = 0; c < s.length; c++)
es = s[c].split('^');
rk = 1000;
if (es[3] == null) es[3] = '0';
if (es[4] == null) es[4] = '0';
if (parseInt(es[4]) > 10) es[4] = '10';
rn = es[0].search(pat);
if (rn != -1)
rk -= seed * 3;
rk -= parseInt(es[4]);
ct_d = 1;
rn = es[2].search(pat);
if (rn != -1)
rk -= seed;
rk -= parseInt(es[4]);
if (rk < 1000)
es_c = '';
ci_e = es[2].split(' ');
if (ci_e.length < ct_l)
es_c = es[2];
else
for (i = 0; i < ct_l; i++)
es_c += ci_e[i] + ' ';
es_c = es_c.replace(/^\s*|\s*$/g, '');
if (es_c.charAt(es_c.length - 1) == '.' || es_c.charAt(es_c.length - 1) == ',') es_c = es_c.substr(0, es_c.length - 1);
es_c += ' ...';
if (ct == 1 && ct_d == 0)
ct_f = true;
rn = es[2].search(pat);
if (rn > c_s)
t_1 = es[2].substr(rn - (c_s - 1));
rn = t_1.indexOf('. ');
if (rn != -1 && rn < (c_s / 2))
t_1 = t_1.substr(rn + 1);
t_2 = t_1.split(' ');
if (t_2.length > ct_l)
es_c = '';
for (i = 1; i < ct_l + 1; i++)
es_c += ' ' + t_2[i];
if (es_c.charAt(es_c.length - 1) == '.' || es_c.charAt(es_c.length - 1) == ',') es_c = es_c.substr(0, es_c.length - 1);
es_c += ' ...';
ct_f = false;
if (ct_f)
rn = es[2].search(pat);
t_1 = es[2].substr(rn - (c_s / 5));
rn = t_1.indexOf(' ');
if (rn != -1)
t_1 = t_1.substr(rn + 1);
t_2 = t_1.split(' ');
es_c = '';
if (t_2.length > ct_l)
for (i = 1; i < ct_l + 1; i++)
es_c += ' ' + t_2[i];
else
for (i = 1; i < t_2.length; i++)
es_c += ' ' + t_2[i];
if (es_c.charAt(es_c.length - 1) == '.' || es_c.charAt(es_c.length - 1) == ',') es_c = es_c.substr(0, es_c.length - 1);
es_c += ' ...';
tr[a] = rk + '^' + es[0] + '^' + es[1] + '^' + es_c + '^' + es[2] + '^' + es[3] + '^' + es[4];
a++;
tr.sort();
co = a;
if (v_d) co = 0;
function tip_query()
if (od != 'undefined' && od != null) document.forms.tipue.d.value = od;
function tip_header() // this writes the line with the search word
if (co > 0)
ne = nr + tn;
if (ne > co) ne = co;
document.write(tl_12, ' ', tn + 1, ' ', tl_5, ' ', ne, ' ', tl_6, ' ', co, ' ', tl_7, ' ');
if (header_links == 1)
if (t_m == 0)
hd = hd.replace(/\"/gi, '');
wt_h = hd.split(' ');
for (i = 0; i < wt_h.length; i++)
if (wt_h[i].toLowerCase() != 'or' && wt_h[i].toLowerCase() != 'and' && wt_h[i].toLowerCase() != 'not' && wt_h[i] != '+' && wt_h[i] != '-')
if (wt_h[i].charAt(0) == '+' || wt_h[i].charAt(0) == '-' || wt_h[i].charAt(0) == '~')
document.write(wt_h[i].charAt(0));
wt_h[i] = wt_h[i].slice(1, wt_h[i].length);
document.write('<a href="', r_l, '?d=', wt_h[i], '">', wt_h[i], '</a><p> ');
else document.write(wt_h[i] + ' ');
else document.write(hd);
else document.write(hd);
function tip_out()
if (cw_l.length > 0)
document.write(tl_9, ' ', cw_l, '<p>');
if (sp_l.length > 0)
sp_e = encodeURIComponent(sp_l);
document.write(tl_8, ' <a href="', r_l, '?d=', sp_e, '">', sp_l, '</a><p>');
if (co == 0)
if (v_d)
document.write(tl_10);
else
document.write(tl_1);
if (b_q == 1) document.write('<b>', od, '</b>');
else document.write(od);
document.write(tl_2);
return;
if (tn + nr > co) nd = co;
else nd = tn + nr;
for (a = tn; a < nd; a++)
os = tr[a].split('^');
if (b_q == 1 && t_m == 0)
for (i = 0; i < wt.length; i++)
pat = new RegExp("\\~", 'i');
rn = wt[i].search(pat);
if (rn != -1)
tw = wt[i].split('~');
for (c = 0; c < tw.length; c++)
lw = tw[c].length;
pat = new RegExp(tw[c], 'i');
rn = os[3].search(pat);
if (rn != -1)
o1 = os[3].slice(0, rn);
o2 = os[3].slice(rn, rn + lw);
o3 = os[3].slice(rn + lw);
os[3] = o1 + '<b>' + o2 + '</b>' + o3;
else
lw = wt[i].length;
pat = new RegExp(wt[i], 'i');
rn = os[3].search(pat);
if (rn != -1)
o1 = os[3].slice(0, rn);
o2 = os[3].slice(rn, rn + lw);
o3 = os[3].slice(rn + lw);
os[3] = o1 + '<b>' + o2 + '</b>' + o3;
if (b_q == 1 && t_m == 1)
lw = dit.length;
tw = new RegExp(dit, 'i');
rn = os[3].search(tw);
if (rn != -1)
o1 = os[3].slice(0, rn);
o2 = os[3].slice(rn, rn + lw);
o3 = os[3].slice(rn + lw);
os[3] = o1 + '<b>' + o2 + '</b>' + o3;
if (include_num == 1) document.write(a + 1, '. ');
if (os[5] == '0') t_b = '';
if (os[5] == '1') t_b = 'target="_blank"';
if (os[5] != '0' && os[5] != '1') t_b = 'target="' + os[5] + '"';
if (b_t == 0) document.write('<a href="', os[2], '" ', t_b, '>', os[1], '</a>');
if (b_t == 1)
lw = dit.length;
tw = new RegExp(dit, 'i');
rn = os[1].search(tw);
if (rn != -1)
o1 = os[1].slice(0, rn);
o2 = os[1].slice(rn, rn + lw);
o3 = os[1].slice(rn + lw);
os[1] = o1 + '<b>' + o2 + '</b>' + o3;
document.write('<a href="', os[2], '" ', t_b, '>', os[1], '</a>');
if (b_t == 2) document.write('<a href="', os[2], '" ', t_b, '><b>', os[1], '</b></a>');
if (os[3].length > 1) document.write('<br>', os[3]);
if (include_url == 1) document.write('<br><a href="', os[2], '" ', t_b, 'target="_blank">', os[2], '</a>');
document.write('<p>');
function tip_footer()
if (co > nr)
od = encodeURIComponent(od);
var np = Math.ceil(co / nr);
nc = co - (tn + nr);
if (tn > 0) var na = Math.ceil(tn / nr) + 1;
else var na = 1;
if (tn > 1) document.write('<a href="', r_l, '?d=', od, '&n=', tn - nr, '">', tl_3, '</a> ');
if (np < 10)
for (var i = 0; i < np; i++)
var nb = nr * i;
if (nb == tn)
if (b_f == 1) document.write('<b>', i + 1, '</b> ');
else document.write(i + 1, ' ');
else document.write('<a href="', r_l, '?d=', od, '&n=', nb, '">', i + 1, '</a> ');
if (np > 9)
if (na < 8)
for (var i = 0; i < 9; i++)
var nb = nr * i;
if (nb == tn)
if (b_f == 1) document.write('<b>', i + 1, '</b> ');
else document.write(i + 1, ' ');
else document.write('<a href="', r_l, '?d=', od, '&n=', nb, '">', i + 1, '</a> ');
else
var ng = na - 5;
if (np > ng + 9) var nf = ng + 9;
else nf = np;
for (var i = ng; i < nf; i++)
var nb = nr * i;
if (nb == tn)
if (b_f == 1) document.write('<b>', i + 1, '</b> ');
else document.write(i + 1, ' ');
else document.write('<a href="', r_l, '?d=', od, '&n=', nb, '">', i + 1, '</a> ');
if (nc > 0) document.write('<a href="', r_l, '?d=', od, '&n=', tn + nr, '">', tl_4, '</a>');
function tipqueryTask()
get_xml();
tip_header();
tip_query();
tip_out();
tip_footer();
setFocus();
document.getElementById('myform').addEventListener('submit', tipqueryTask());
// event.preventDefault(); Prevent default behaviour (submitting form)
var outputElement = document.getElementById('outputHeader');
outputElement.innerHTML = '<script language="JavaScript" type="text/javascript" >tip_out()></script>';
var outputElement = document.getElementById('outputQuery');
outputElement.innerHTML = '<script language="JavaScript" type="text/javascript">tip_query()></script>';
var outputElement = document.getElementById('outputOut');
outputElement.innerHTML = '<script language="JavaScript" type="text/javascript">tip_out()</script>';
var outputElement = document.getElementById('outputFooter');
outputElement.innerHTML = '<script language="JavaScript" type="text/javascript">tip_footer()></script>';
false;
进一步研究,我认为这可能与必须将 XML 文件列入白名单和对 js 文件进行修改有关,但如果是这样,那对我来说太复杂了。我自己不会写javascript,我只是一个业余爱好者,只能调整其他人的脚本以满足我的需要。
如果您需要任何其他信息,请告诉我。非常感谢
index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0020)http://www.tipue.com -->
<html>
<head>
<title>Address % Telephone Search</title>
</head>
<body>
<form id="myform" method="get" name="tipue" action="results.html">
<table cellpadding=0 cellspacing=0 class="form_table"><tr>
<td class="form_td_left">
<input type="text" name="d" id="searchBox" class="field">
</td>
<td class="form_td_right">
<input type="submit" value="Go" class="button">
<br />
</td></tr></table>
</form>
<!-- End of form section -->
<p>
Enter Tipue or other search terms in the example above.
<p>
This example uses an <a href="http://www.tipue.com/products/tipueJS/started/xml.cgi">XML</a> data file. For more information see <a href="http://www.tipue.com/products/tipueJS/started/">Getting Started</a>.
<br>
</body>
</html>
你还需要
结果.html (以下修改代码)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0020)http://www.tipue.com -->
<html>
<head>
<title>Tipue JS XML Example Search Results</title>
</head>
<body>
<form id="myform" method="get" name="tipue" action="results.html">
<table cellpadding=0 cellspacing=0 class="form_table"><tr>
<td class="form_td_left">
<input type="text" name="d" class="field" id="searchBox">
</td>
<td class="form_td_right">
<input type="submit" value="Go" class="button">
</td></tr></table>
</form>
<!-- End of form section -->
<br>
<div id="outputQuery"></div>
<div id="outputHeader"></div>
<div id="outputOut"></div>
<div id="outputFooter"></div>
<script language="JavaScript" type="text/javascript" src="combinedTipue.js"></script>
<br>
<hr>
</body>
</html>
如果您将清单更改为版本:1,您会看到它可以正常工作,但不是版本:2。感谢您的帮助,非常感谢
添加 popup.js 删除
【问题讨论】:
报错信息是什么,相关的脚本是什么?顺便说一句,您的清单包含很多垃圾。例如,background_page
不是browser_action
中的可识别键。在权限中,tipue.js
、tipue_set.js
和tipue_data.xml
可以去掉。
错误消息是:尝试安装此扩展时出现警告:权限“tipue.js”未知或 URL 模式格式错误。权限“tipue_set.js”未知或 URL 模式格式错误。权限“tipue_data.xml”未知或 URL 模式格式错误。我按照您的建议删除了它们,警告消失了,但搜索功能仍然不起作用。 XML 代码是: 我已经可以使用 popup.js 脚下的这段代码了:
function tipqueryTask() get_xml(); tip_header(); tip_query(); tip_out(); tip_footer();
function clickHandler()
setTimeout(tipqueryTask, 5000);
var alreadyrunflag=0 //flag to indicate whether target function has already been run
if (document.addEventListener)
document.addEventListener("DOMContentLoaded", function()alreadyrunflag=1; clickHandler(), false)
else if (document.all && !window.opera)
document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>')
var contentloadtag=document.getElementById("contentloadtag")
contentloadtag.onreadystatechange=function()
if (this.readyState=="complete")
alreadyrunflag=1
clickHandler()
注意 setTimeout 是 5 秒。似乎正在发生的事情是当我点击扩展时,index.html 打开并且我有 5 秒的时间输入搜索查询(否则它会显示“空白搜索”(这是属性/变量之一??在tipue_set .js)) 在我按 Enter 键后,会出现 results.html 页面,但其中没有结果,然后一旦 5 秒结束,就会出现另一个页面,上面有实际结果。 SetTimeout 正在从 popup.js 运行点击处理,但我无法弄清楚如何让它从结果页面运行,该结果页面应该具有用于 tipqueryTask 中所有功能的内联 js。我尝试将它们放在单独的脚本中,但没有奏效。有任何想法吗?如果没有,我将不得不像这样离开它。这并不理想,但总比没有好。
【讨论】:
以上是关于Chrome 扩展清单版本:2 xml的主要内容,如果未能解决你的问题,请参考以下文章