Chrome web extension DeclarativeNetRequest does not block intercept requests in main_frame - google-chrome-extension

I am migrating our v2 extension to manifest v3 and in the process of converting from the deprecated WebRequest API to the new DeclarativeNetRequest, I've found that the following rule does not intercept requests that originate while navigating through links, yet it does intercept the same request if the URL is entered into the address bar. I need it to intercept all requests and URL changes that happen in the top frame.
[
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": { "regexSubstitution": "some local web server address here" }
},
"condition": {
"regexFilter": "^(https?\\://)?[^\\:]+$",
"resourceTypes": [ "main_frame" ]
}
}]

Turned out it's a bug in Opera's requests originating from the Speed Dial shortcuts. Chromium Canary does not exhibit the same issue with the start page shortcuts.
I have reported the issue to the Opera team.

Related

Why doesn't this declarative net request rule work?

I'm trying to block a website with a chrome extension that uses the new declarative net request API for Manifest V3, but it isn't working at all. I have added the permission in the manifest and made sure to add the priority, id, action and conditions, but it still doesn't do anything at all. Since I am blocking only one domain, I tried changing the domain list in the conditions from "domains" to "domain" but this just blocks every domain. Here is the applicable part of my manifest. I'm not sure why, but when I open the website in a private/incognito tab, occasionally, it will work.
"declarative_net_request" : {
"rule_resources" : [{
"id": "rules1",
"enabled": true,
"path": "rules.json"
}]
},
"permissions": [
"declarativeNetRequest"
],
Here is my rules.json file.
[{
"id": 1,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"domains": ["google.com"],
"resourceTypes": ["main_frame"]
}
}]
You need to change the "Domains" tag to "requestDomains" or "initiatorDomains" since the "Domains" tag is deprecated. I am assuming that the google.com is your initiator Domain which means you want to block all requests originating from google.com to any destination website. If you want to block google.com from being a destination website i.e you want to stop any requests being made to google.com, you need to use the "urlFilter" tag instead.
I ran into the same problem, google does a terrible job at telling us what's deprecated. domains was deprecated and we have to use initiatorDomains instead:
what worked for me was:
inside your rules conditions -
urlFilter: "https://example.com" to block a request going to your "https://example.com"
and then:
initiatorDomains:["mail.google.com"] to block a request coming from "mail.google.com" (just an example)
must include in the manifest version 3
"host_permissions": [ "<all_urls>" ]
if I had that example on how to block from and to, it'd have saved me a lot of time. I hope this helps

how to open url in other browser using adaptive card in microsoft teams bot?

I am using microsoft teams bot framework and I want a adaptive card with a button to open url in popout(other browser)
By using (Actions.openUrl) it Opens a URL in the default browser.
and want it to open in other browser
This is what i have tried and I am using node.js
var card = {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [{
"type": "Container",
"items": [{
"type": "TextBlock",
"text": `${session.message.text}`,
"weight": "bolder",
"size": "medium"
}
]
},
{
"type": "Image",
"url": `${bodyData.img}`
},
{
"type": "Container",
"items": [{
"type": "TextBlock",
"text": `${bodyData.calendar}`,
"wrap": true
}]
}
],
"actions": [
{
"type": "Action.openUrl",
"title": "Open in Popout",
"url": `${bodyData.url}`
}
]};
Like paul cheung said, you cannot specify the browser in an openUrl button. Not only that, you cannot specify the URL's "target" in an openUrl button. You can see here that the only thing you can specify is the URL itself. The details of how the URL gets opened are the responsibility of the client and the bot has no control over them.
I think you have a few options.
Option 1
If you really want to open a browser window like a popup, you can try creating a sort of redirect page that the card would link to. When the user clicks the button, your redirect page would open in a new tab of the current browser window and then whatever client-side code you've set up would open the target page in a new window and close the redirect page's tab.
Option 2
The conventional way to do what you're talking about in Teams is to use a task module. Depending on what your URL contains, you might even consider putting a card in your task module instead of a web page.
This action type specifies a URL to launch in the default browser, You can NOT specify the browser at moment. BTW, the default browser is a system level setting(default program) as you know.
Update:
like Kyle said, if task module is your option, Here is a repository you can take a quick look, it includes all necessary code. popout window was triggered in javascript and adaptive card.

PWA manifest loads but I cant get a install prompt

I managed to get my PWA to complete all the chrome dev tools tests but I still cannot get an install prompt to fire.
www.billtravis.net/pwa/
from what I've seen everywhere the install prompt should fire when the manifest loads before the service worker installs.
This PW also needs to live on an IIS server, which won't even register the worker.
Any ideas?
{
"name": "SYLVANIA LightPRO",
"short_name": "LightPRO",
"icons": [
{
"src": "/img/image-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/pwa/?homescreen=1",
"scope": "/",
"display": "standalone",
"background_color": "#ff6600",
"theme_color": "#ffffff"
}
Probably it due to lack of image sizes definitions in manifest.json which were required by web browser. I can see you have only 512 while different browsers expect a different set of images. So if you would not like to care about that differences in PWA implementation between the browsers, you can use pwacompat:
<script async src="path/to/pwacompat.min.js"></script>
This "polyfill" will generate all necessary images (if not specified in manifest.json) and will add metatags (required by ios for example)

The manifest has invalid search provider url which is not owned by the developer - chrome extension

I am working on a chrome extension which overrides the chrome settings. And for instance I am overriding the default search engine to my own custom search engine.
While testing it locally it works great, but when I tried to upload it, it gives me the following errors.
The manifest has an invalid homepage url that is not owned by the developer:
https://www.my-search.com/.
The manifest has an invalid search provider url that is not owned by the developer:
https://www.my-search.com/search?aid=4898&zoneid=89111407&q={searchTerms}.
Upload
Win Free Gifts
Short name: Win Free Gifts
Version 1.0 by aloni.rozi
The manifest has an invalid homepage url that is not owned by the developer: https://www.my-search.com/.
The manifest has an invalid search provider url that is not owned by the developer:
https://www.my-search.com/search?aid=4898&zoneid=89111407&q={searchTerms}.
Below is my manifest.json file :
{
"name":"Win Free Gifts",
"short_name": "Win Free Gifts",
"author" : "Nadeem Ahmad",
"description":"Win 1000's of gifts every day ! ",
"version":"1.0",
"manifest_version":2,
"icons":{
"16":"icons/job_icon.png",
"32":"icons/job_icon.png",
"64":"icons/job_icon.png"
},
"browser_action":{
"default_icon":"icons/job_icon.png",
"default_popup": "popup.html"
},
"chrome_url_overrides" : {
"newtab": "show.html"
},
"chrome_settings_overrides": {
"homepage": "https://www.my-search.com/",
"search_provider": {
"name": "Nadeem Ahmad",
"keyword": "keyword.__MSG_url_domain__",
"search_url": "https://www.my-search.com/search?aid=4898&zoneid=89111407&q={searchTerms}",
"alternate_urls": [
"https://www.my-search.com/search?aid=4898&zoneid=89111407&q={searchTerms}",
"https://www.my-search.com/search?aid=4898&zoneid=89111407&q={searchTerms}"
],
"encoding": "UTF-8",
"is_default": true
}
},
"permissions":[
"cookies",
"tabs",
"notifications",
"<all_urls>"
]
}
You have to verify the search provider website (in your case, https://www.my-search.com) in the Developer's Dashboard.
According to the documentation for Settings Overrides:
Web sites used in the settings API must be verified (via Webmaster
Tools) as being associated with that item in the Chrome Web Store.
Note that if you verify ownership for a domain (for example,
http://example.com) you can use any subdomain or page (for example,
http://app.example.com or http://example.com/page.html) within your
extension

Google Chrome extension get IP address of server

I had a good idea, which kind of revolves around ips from the server the user is on.
Im very new to making a google chrome extension, but i am good at the programming languages that requires to build one .
Question: Can I get a IP from a server that the user is on? and if so how would you do this?
I was thinking just AJAX the url to my own server which then pings the server which would get the ip and returns that/stores it some where.
You can get current URL of tab\web Pageuser is currently browsing using chrome.tabs API
Demonstration
chrome.tabs.query({
"currentWindow": true, //Filters tabs in current window
"status": "complete", //The Page is completely loaded
"active": true // The tab or web page is browsed at this state,
"windowType": "normal" // Filters normal web pages, eliminates g-talk notifications etc
}, function (tabs) { //It returns an array
for (tab in tabs) {
_url_i_need = tabs[tab].url;
//Do AJAX Stuff here
}
});
Ensure you declare tabs permission in your manifest as shown here
{
"name": "My extension",
...
"permissions": [
"tabs"
],
...
}
References
Tabs API

Resources