Here is my manifest.json file:
{
"manifest_version": 2,
"permissions": ["tabs", "storage", "webRequest", "<all_urls>"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["assets/js/jquery-3.3.1.min.js", "blocker.js"]
}
],
"background": {
"scripts": ["background.js"]
},
"options_ui": {
"page": "background-page.html",
"browser_style": true
}
}
and my blocker.js file:
function cleanPage(tabId, changeInfo, tabInfo) {
console.log("I am in cleanPage");
}
try {
console.log("browser : ");
console.log(browser);
console.log("browser.tabs : " + browser.tabs);
browser.tabs.onUpdated.addListener(cleanPage);
} catch(err) {
console.log("err : ", err);
}
And I get this error:
browser.tabs : undefined blocker.js:114:3
err : TypeError: "browser.tabs is undefined"
My setup:
- Mozilla Firefox 65.0.1
- Ubuntu 18.04
I don't really understand this error, since I'm doing exactly what is written in the Mozilla Tutorial. Does anyone know why this error does appear?
My blocker.js file was in the content_scripts. I moved it to the background_scripts and it worked.
Only the files from the background_scripts can access the browser.tabs API.
My new manifest.json file:
{
"manifest_version": 2,
"permissions": ["tabs", "storage", "webRequest", "<all_urls>"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": []
}
],
"background": {
"scripts": ["assets/js/jquery-3.3.1.min.js", "background.js", "blocker.js"]
},
"options_ui": {
"page": "background-page.html",
"browser_style": true
}
}
Related
i am migrating to manifest v3 from manifest v2 and getting error when click on the extension icon
TypeError: Cannot read properties of undefined (reading 'createElement')
at ja (jquery-3.2.1.min.js:306:23)
at jquery-3.2.1.min.js:891:111
at jquery-3.2.1.min.js:907:6
at jquery-3.2.1.min.js:6:9
at jquery-3.2.1.min.js:7:2
at worker_wrapper.js:2:5
306 line code in jquery-3.2.1.min.js
function ja(a) {
var b = n.createElement("fieldset");
try {
return !!a(b)
} catch (c) {
return !1
} finally {
b.parentNode && b.parentNode.removeChild(b), b = null
}
}
here is my manifest v 3 code and chrome extension does not give any error when i upload in
chrome://extensions/
{
"background": {
"service_worker": "worker_wrapper.js"
},
"action": {
"default_icon": {
"19": "img/icon19.png"
},
},
"default_locale": "en",
"icons": {
"128": "img/icon128.png"
},
"manifest_version": 3,
"name": "sample",
"permissions": [ "\u003Call_urls>", "tabs", "activeTab", "storage", "unlimitedStorage", "notifications", "clipboardWrite", "downloads", "cookies" ],
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "1.0.4",
"host_permissions": [
"https://*.website.com/*"
],
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
"js": ["libs/jquery-3.2.1.min.js"]
}
],
"web_accessible_resources": [
{
"resources": ["toolbar_res/*","libs/*","js/*","html/*", "img/*", "_locales/*", "css/*"],
"matches": ["<all_urls>"],
"use_dynamic_url": true
}]
}
worker_wrapper.js is this
try { importScripts("libs/jquery-3.2.1.min.js","js/event.js"); } catch (e) { console.log(e); }
any help/direction in right direction will be great
Error when Migrating Manifest V2 to Manifest V3
with the error message: Could not establish connection. Receiving end does not exist.
It occurred between sendMessage and onMessage
manifest.js
{
"update_url": "https://clients2.google.com/service/update2/crx",
"manifest_version": 3,
"name": "AAANAME2.7",
"version": "2.7",
"description": "AAA NAME",
"action": {
"default_icon": "logo_19.png",
"default_popup": "popup.html"
},
"default_locale": "ko",
"icons": {
"16": "logo_16.png",
"19": "logo_19.png",
"48": "logo_48.png",
"128": "logo_128.png"
},
"background": {
"service_worker": "bg.js"
},
"options_page": "options.html",
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"content_scripts": [
{
"all_frames": false,
"css": [
"achecker.css"
],
"js": [
"lib/rainbowColor.js",
"lib/colorInspector.js",
"lib/KWAX.js",
"i18n.js",
"lib/jquery-3.6.0.min.js"
],
"matches": [
"http://*/*",
"https://*/*"
]
}
],
"permissions": [
"activeTab",
"tabs",
"contextMenus", // extension right click popup menu
"downloads",
"storage",
"tts"
],
"web_accessible_resources": [
{
"resources": [
"images/*.png",
"popup-attach-tagname.html",
"achecker.css"
],
"matches": [
"http://*/*",
"https://*/*"
]
}
]
}
content.js
const captureRequest = new Promise(function(resolve, reject) {
console.log("appId=" + appId);
chrome.runtime.sendMessage(appId, {
capture: "yes"
}, function(response) {
console.log('return from bg...')
if (!chrome.runtime.lastError) {
if (!response) {
console.log('Fail Capture')
reject(new Error('Fail Capture'));
} else {
console.log('succ Capture')
resolve(response)
}
} else {
console.log(chrome.runtime.lastError)
// returned : Could not establish connection. Receiving end does not exist."
}
});
});
bg.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.capture == "yes") {
chrome.tabs.captureVisibleTab(
null, {
format: "png",
quality: 100
},
function(dataUrl) {
sendResponse({
src: dataUrl
});
}
);
return true;
} else if (request.ignoreCommon) {
// some else
}
});
I have created a chrome plugin but it is running on all google sites except gmail, how do I make it run on gmail?
My manifest file:
{
"manifest_version": 2,
"name": "drc",
"version": "0.1",
"background": {
"scripts": ["bg.js"]
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["content.js", "onclic.js", "Jquery.js"],
"css": ["drpdwn.css"]
}
],
"browser_action": {
"default_title": "Append Test Text"
},
"permissions": [
"tabs",
"activeTab",
"https://mail.google.com/*",
"http://mail.google.com/* "
]
}
Error I get is, cannot read property 'parentNode' of null
I was looking for without success.
I want to get the status of my requests from my extension but I can not get it.
Manifiest
{
"manifest_version": 2,
"name": "Pixel Checker TT",
"description": "This extension validate your pixels and its requests",
"version": "1.6",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"background": {
"persistent": true,
"scripts": ["popup.js"]
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["sources/js/jquery-3.0.0.min.js","content.js"]
}
],
"permissions": [
"tabs",
"activeTab",
"webRequest",
"webRequestBlocking",
"*://*.mydomain.co/",
"*://*.myotherdomain.co/"
]
}
popup.js or background code
chrome.webRequest.onCompleted.addListener(function(details) {
for (var i = 0; i < details.requestHeaders.length; ++i) {
console.log(details.requestHeaders[i].url);
console.log(details.requestHeaders[i].statusCode);
}
},
{urls: ["<all_urls>"]},
['blocking','requestHeaders']);
The problem is that I dont have errors just aren not printed the info. I also tried to put the info in a div with $('#pixelsFound').text(details.requestHeaders[i].url)
but doesn't work too.
Hello i am trying to create a chrome extension. It like tampermonky. It add some user script. But the problem is some variable show undefined, But when i use the same script on tampermonky there is no error.
My extension manifest.json is
{
"name": "SayHello",
"description": "It will say hello when a page finishied load.",
"version": "0.4",
"permissions": [
"tabs",
"<all_urls>",
"storage"
],
"browser_action": {
"default_icon": "icon.png"
},
"options_page": "options.html",
"content_scripts": [
{
"exclude_globs":[],
"include_globs":["*"],
"matches": [
"http://www.amazon.com/*",
"https://www.amazon.com/*"
],
"js": ["email.js"],
"run_at": "document_end"
}
],
"converted_from_user_script": true,
"manifest_version":2
}
and email.js is.
P.when("jQuery","ready").execute(function(t){
var i="http://www.amazon.com/gp/profile/A3U7NCDBQ95EJM/customer_email";
t.get(i,function(t){
var o=t.data.email;
console.log('o:'+o);
});
return t;
});
error massage is Uncaught ReferenceError: P is not defined