我希望我的Google Chrome扩展程序将google.com/trade的HTML更改为???
,将yahoo.com/trade的HTML更改为<<<
,但是我在做了一些研究后找到了这段代码不管用。我已经确定我的清单是正确的,并且我拥有所需的所有权限,但由于某种原因它只是没有工作。
$(function() {
if (window.location.href.match(/google\.com\/trade/i)) {
$("html").html("???");
} else if (window.location.href.match(/yahoo\.com\/trade/i)) {
$("html").html("<<<");
}
});
清单
{
"background": {
"scripts": [ "jquery.js", "background.js" ]
},
"browser_action": {
"default_icon": "Icon.png"
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"description": "A",
"homepage_url": "http://www.google.com/User.aspx?ID=1",
"icons": {
"128": "Icon.png",
"16": "Icon.png",
"48": "Icon.png"
},
"incognito": "split",
"manifest_version": 2,
"name": "a",
"permissions": [ "unlimitedStorage", "tabs", "notifications", "tabCapture", "http://*.google.com/*", "https://*.yahoo.com/*"],
"short_name": "a",
"version": "1",
"web_accessible_resources": ["https://*.google.com/*", "http://*.yahoo.com/*", "Icon.png" ]
}
谢谢!
答案 0 :(得分:-1)
你试过吗
if(document.URL.indexOf('google.com/trade') > -1){
$('body').html('???');
}
if(document.URL.indexOf('yahoo.com/trade') > -1){
$('body').html('???');
}
或类似的东西?