我有一个Chrome扩展,我想操纵GitHub上的一些DOM。当我刷新任何给定的页面时,所有工作都按预期工作,但如果我正常导航到该页面,则通常不会执行脚本。Chrome扩展只能在刷新时运行,而不能在页面导航上运行
manifest.json的
{
"manifest_version": 2,
"name": "Name",
"description": "Detailed description",
"version": "1.3.5",
"content_scripts": [{
"matches": ["https://github.com/*/*/issues/*"],
"js": ["jquery-2.1.0.min.js", "index.js"]
}],
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"activeTab",
"https://ajax.googleapis.com/"
]
}
index.js
$(document).ready(function() {
// DOM manipulating code
// removed for brevity
});
Github使用历史API的网站导航,你将不得不挂钩历史pushState函数,[如何通过history.pushState得到关于历史变化的通知?](http://stackoverflow.com/questions/4570093/how-to-get-notification-about-changes-of-the-history-via-history-pushstate) –
@ZigMandel该帖子中的建议解决方案不适用于我的情况所以我开了一个新的问题。 – James
@詹姆斯,如果你已经尝试了一些东西,但它不起作用,那么你应该在你的问题中提及它。不这样做只会浪费你要求帮助你的人的时间。 – Makyen