I am currently building a simple google chrome extension to prank my brother. The Extension simply deletes the old page and replaces it with HTML and CSS copied off of the "You have no internet" page, In essence making the user think they don't have internet when they do. The following is the content script injected into all new pages:
var hed = document.head;
var bod = document.body;
document.head.parentElement.removeChild(document.head);
document.body.parentElement.removeChild(document.body);
document.write(/*Copy of "no internet" page source here*/);
This script works perfectly. The only page i don't want the change to occur on is the google chrome New Tab page. The way to go about normally excluding pages is to specify it in the Extensions manifest.json file under the content scripts. Here was my original manifest.json setup:
{
"manifest_version": 2,
"name": "No Internet Extention",
"description": "Make people with this extention think they have no internet",
"version": "1.0",
"content_scripts":
[
{
"matches": ["*://*/*"],
"js": ["bup.js"]
}
],
"permissions":
[
"activeTab",
"https://ajax.googleapis.com/"
]
}
I have currently tried the following set ups in my manifest.json file content_scripts section in order to exclude the Chrome New Tab page to no avail:
"matches": ["http://*/*", "https://*/*"]
I assumed this would exclude it because This page on the google product forms Told me that the URL of the New Tab page is "chrome://newtab", which is not a HTTP: or HTTPS: Protocol.
I also Tried:
"matches": ["*//*/*"]
"exclude_matches": ["chrome://newtab"]
"matches": ["*//*/*"]
"exclude_matches": ["chrome://newtab/*"]
"matches": ["*//*/*"]
"exclude_matches": ["*://newtab/*"]
"matches": ["*//*/*"]
"exclude_globs": ["chrome://newtab"]
None of these have worked and the content script still executes on the new tab page. I believe the root of the problem here is that my New Tab URL is incorrect. My research for excluding pages was done here: Google Content Scripts Page. The real question is: Does anyone know the proper URL for the google new tab page or how to go about excluding it in a manifest file?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…