WebExtension: Bypass permission denied to access property "target" - firefox-addon-webextensions

Using FF WebExtension, I am trying to clone an element from a website that I don't own. This is what I use(taken from W3C).
// Get the last <li> element ("Milk") of <ul> with id="myList2"
var itm = document.getElementById("myList2").lastChild;
// Copy the <li> element and its child nodes
var cln = itm.cloneNode(true);
// Append the cloned <li> element to <ul> with id="myList1"
document.getElementById("myList1").appendChild(cln);
However, this error appears:
Error: Permission denied to access property "target"
Here is my manifest:
{
"manifest_version": 2,
"name": "w",
"version": "0.1",
"description": "w",
"icons": {
"48": "icons/border-48.png"
},
"content_scripts": [
{
"matches": ["http://localhost/*"],
"js": ["rh-addbutton.js","rh-addpage.js"]
}
],
"permissions": ["http://localhost/*"]
}
Am I missing a permission? I can't find the right permission on MDN.

Related

How can i append react index.html file when i click a chrome extension

I want to make a chrome extension using react. The problem I face I can't load the index.html file that is inside the public directory. My goal is when I click my chrome extension then the index.html file append inside the existing web page
This is my manifest.json code :
{
"name": "Demo Exe",
"description": "The demo chrome extension",
"version": "1.0",
"manifest_version": 2,
"permission": ["active"],
"permissions": ["storage", "activeTab", "scripting"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["./index.js"]
}
]
}

Cannot read property 'tenant_id' of undefined using Auth0

I've been setting up Single Sign On with Active Directory for our application according to this instruction:
https://auth0.com/docs/authenticate/identity-providers/enterprise-identity-providers/azure-active-directory/v2#register-your-app-with-azure-ad
However, after redirect to the Microsoft page i get this error:
Cannot read property 'tenant_id' of undefined
In my Auth0 Dashboard under
Monitoring > Logs
i found this error log:
{
"date": "2022-02-28T09:05:51.484Z",
"type": "f",
"description": "Cannot read property 'tenant_id' of undefined",
"connection_id": "",
"client_id": "XXXXXXX",
"client_name": "XXXXXXX (DEV)",
"ip": "195.192.198.XXX",
"user_agent": "Chrome 98.0.4758 / Mac OS X 10.15.7",
"details": {
"body": {},
"qs": {
"client_id": "XXXXXXXX",
"redirect_uri": "http://localhost:3000",
"scope": "openid profile email",
"response_type": "code",
"response_mode": "query",
"state": "WmdOOEpBTUlKTG5mQks1LjJLY3JabEwyUVBJTDZNeTdVZE1TZjNGVDhFUw==",
"nonce": "OG94dlNjbEFyUDJXcnNmeWNEamhSa1IxWHVSV08wcUxZS0tVQ3NwTjRjWA==",
"code_challenge": "8tWkNmx5qUlDVpIUCJy68B1lWwPa6qi1ZpMjq-4WZAc",
"code_challenge_method": "S256",
"auth0Client": "XXXXXXXXXX"
},
"error": {
"message": "Cannot read property 'tenant_id' of undefined",
"oauthError": "access_denied",
"type": "oauth-authorization"
},
"session_id": "7aXIltPAKa0e0vQhqyyAblzIWjmvbiy",
"riskAssessment": {
"confidence": "high",
"version": "1",
"assessments": {
"UntrustedIP": {
"confidence": "high",
"code": "not_found_on_deny_list"
},
"NewDevice": {
"confidence": "high",
"code": "initial_login"
},
"ImpossibleTravel": {
"confidence": "high",
"code": "initial_login"
}
}
}
},
"hostname": "XXXXXXX.eu.auth0.com",
"user_id": "XXXXXXXX",
"user_name": "XXXX#XXXX.com",
"audience": "https://XXXXXXX.eu.auth0.com/userinfo",
"scope": [
"openid",
"profile",
"email"
],
"auth0_client": {
"name": "auth0-react",
"version": "1.9.0"
},
"log_id": "900202202280905566349491050266127672706556666XXXXXXX",
"_id": "900202202280905566349491050266127672706556666XXXXXXX",
"isMobile": false
}
What i've been trying so far:
Created a new Auth0 account and connect the sample React Login application (https://github.com/auth0-samples/auth0-react-samples/tree/master/Sample-01) provided by Auth0 to the same Active Directory endpoint (works)
Connect our Development Auth0 account to Active Directory using the Auth0 React sample app (doesn't work)
Connect our React development application to the Active Directory Endpoint (throws error as shown above)
Playing around with different Callback URLs. Added some URLs and Routes to the existing http://localhost:3000 (doesn't work)
I think this error was caused by wrong settings in our Auth0 account since creating a new account doesn't show any problems. I also don't see any issues caused by setting up the Active Directory application.

Error: ngRepeat:dupes Duplicate Key in Repeater (even though no dupes in data)

<div ng-repeat="item in skippedFiles.openCategories">
{{skippedFiles.openCategories}} prints:
[
{
"name": "Files with Code Differences",
"description": "Customizedfiles in which the code is different between the instance record and the platform record",
"sys_id": "undefined"
},
{
"name": "Files Deleted in the Instance",
"description": "Files which have been deleted by a developer or system administrator during thecustomization of out-of-box code",
"sys_id": "49e13d4113b8e3442a393ac2e144b0e9"
},
{
"name": "Files Deleted in Platform",
"description": "Files which are no longer a part of a platform release, resulting in deletion of file",
"sys_id": "6912358113b8e3442a393ac2e144b025"
}
I have validated JSON and there are no dupes in it and yet angular throws Duplicate Key in Repeater.
I have tried track by $index but that does not help.
Not sure what's wrong in your code, unless you paste the entire code here, would be difficult to answer.
I have created a code for you based on your question.
Have a look and let me know.
function LoginController($scope) {
$scope.user = {
firstName: "Foo",
lastName: "Bar"
};
$scope.skippedFiles = {};
$scope.skippedFiles.openCategories = [
{
"name": "Files with Code Differences",
"description": "Customizedfiles in which the code is different between the instance record and the platform record",
"sys_id": "undefined"
},
{
"name": "Files Deleted in the Instance",
"description": "Files which have been deleted by a developer or system administrator during thecustomization of out-of-box code",
"sys_id": "49e13d4113b8e3442a393ac2e144b0e9"
},
{
"name": "FilesDeleted in Platform",
"description": "Files which are no longer a part of a platform release, resulting in deletion of file",
"sys_id": "6912358113b8e3442a393ac2e144b025"
}
]
};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app ng-controller="LoginController">
<div>Hello {{ user.firstName }}</div>
<div ng-repeat="item in skippedFiles.openCategories">
{{item.name}}
{{item.description}}
</div>
</div>

WebExtensions: browser.webRequest.onCompleted never fires

I'm using the Firefox WebExtensions API with the following background script
var log = console.log.bind(console)
log('hello world from browser extension')
// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onCompleted
var filter = { urls: '<all_urls>' }
var extraInfoSpec = ['tlsInfo', 'responseHeaders']
browser.webRequest.onCompleted.addListener(function(details){
log(`Woo got a request, here's the details!`, details)
}, filter, extraInfoSpec)
log('Added listener')
After loading the script from about:debugging, I see the following output in DevTools:
hello world from browser extension
I do not see any output- there is no data from browser.webRequest.onCompleted.addListener and there is no 'Added listener' message.
How do I make browser.webRequest.onCompleted work?
For completeness, my manifest.json is below:
{
"manifest_version": 2,
"name": "Test extension",
"version": "1.0",
"description": "Test extension.",
"icons": {
"48": "icons/border-48.png"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
],
"permissions": [
"webRequest",
"webRequestBlocking"
]
}
The webRequest API is only available to background scripts. You seem to using it inside a content script.
urls in var filter = { urls: '<all_urls>' } needs to be be an array ['<all_urls>'].
'tlsInfo' in extraInfoSpec doesn't exist, I don't know where it comes from.
You need to specify an additional <all_urls> permission in your manifest.
script.js
var filter = { urls: ['<all_urls>'] }
var extraInfoSpec = ['responseHeaders']
browser.webRequest.onCompleted.addListener(function(details){
console.log(`Woo got a request, here's the details!`, details)
}, filter, extraInfoSpec)
console.log('Added listener')
manifest.json
{
"manifest_version": 2,
"name": "Test extension",
"version": "1.0",
"description": "Test extension.",
"icons": {
"48": "icons/border-48.png"
},
"background": {
"scripts": ["script.js"]
},
"permissions": [
"webRequest",
"webRequestBlocking",
"<all_urls>"
]
}

Cannot Access WebExtension APIs

I have the following manifest.json:
{
"manifest_version": 2,
"name": "Application Name",
"version": "1.0",
"description": "blah blah blah",
"icons": {
"48": "icons/icon-48.png",
"96": "icons/icon-96.png"
},
"permissions": [
"activeTab",
"tabs",
"history",
"storage"
],
"browser_action": {
"default_icon": "icons/icon-32.png",
"default_title": "Title",
"default_popup": "popup/popup.html"
},
"content_scripts": [{
"matches": [
"<all_urls>"
],
"js": [
"content_scripts/script1.js",
"content_scripts/script2.js"
]
}]
}
I have access to the the storage API (browser.storage is defined) in my content scripts, but both the history and tabs APIs (browser.tabs and browser.history) are undefined. Am I missing something in the manifest to get access to these permissions?
One of the few WebExtensions APIs that is available for content scripts is browser.storage. Most WebExtensions APIs can only be accessed when using a background script. Using message passing you can still call those APIs (what you do is basically calling a function in the background script from within the content script). Please see the example on this page: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/sendMessage
See also Firefox WebExtention API: TypeError: browser.browserAction is undefined for a similar problem.

Resources