My Chrome extension writes to local storage: why can't I see or delete the data in Dev Tools? [duplicate] - google-chrome

Chrome DevTools has a handy inspector for Local Storage and Session Storage, but is there nothing to inspect chrome.storage.sync?
chrome://sync-internals/ doesn't seem to display the actual contents of the synchronized storage per extension.

Storage Area Explorer extension provides a UI for viewing, editing, clearing, importing and exporting of chrome.storage.local, chrome.storage.sync, localStorage and sessionStorage.
In the future this feature may be implemented natively: https://crbug.com/848752.
Warning for ManifestV3: since devtools for service worker doesn't show storage, you'll have to open any visible page of your extension like the popup or options, right-click the page, then click "inspect", then go to Storage Explorer. If your extension doesn't have any visible pages, you can open chrome-extension://ID/manifest.json where ID is the id of the extension as shown in chrome://extensions page. Another method is to right-click any script from your extension in devtools (when you inspect the content script or service worker), then click "Open in a new tab". You can add a bookmark for this tab to open it quickly next time.

Visit chrome://sync-internals/
Click Sync Node Browser tab and wait for it to load (may give a blank screen or in progress cursor)
Click expansion triangle in the sidebar for Extension settings
Click on individual settings in the sidebar to see their values and other metadata

A poor workaround is to call get and obtain all the stored values. Of course, this doesn't let you conveniently edit them:
chrome.storage.sync.get(null, function callback(items) { console.log(items) });

Related

Allow screen sharing current tab in Chrome using Azure Communication Services (ACS)

I'm writing an Angular web app for VoIP communication that includes screen sharing using Azure Communication Services.
When screen sharing is initiated in Microsoft Edge, the pop-up for selecting screen/window/tab includes the current tab with the call itself. Google Chrome on the other hand does not offer current tab in the pop-up menu (it offers other opened tabs). I can only screen share the whole chrome window.
I've read that Google Chrome can record or share stream from browser using getDisplayMedia() and selfBrowserSurface can be set to the value 'include' to include the current tab in the pop up menu.
Problem is, that I don't know how to use this method in combination with Azure Communication Services and it is not recommended to use in combination with ACS. ACS Best Practices Documentation clearly states
Your application shouldn't use native browser APIs like getUserMedia or getDisplayMedia to acquire streams outside of the SDK.
Is there any way to force Google Chrome to allow screen sharing current tab?
Or even better solution: Is there any way to programmatically select current tab without displaying Pop-Up Window at all? (I can see the security concern in this case)
Chrome is rolling out the change to hide the current tab (unless selfBrowserSurface is set to 'include') along with the reordering of tabs. See https://bugs.chromium.org/p/chromium/issues/detail?id=1407021#c7 for details.
For 1.10.0-beta.1 version of the sdk, a local run of calling sample app
https://github.com/Azure-Samples/communication-services-web-calling-tutorial
shows the existing tab as an option:
sample screenshot
on this version of chrome:
screenshot

How to avoid Chrome's automaticDownload limitations

I have a site that offers users the chance to download files by clicking a button which loads a rest request then uses file-saver to download it.
The second time a user in Chrome clicks this they get a popup blocker. The message is "This site attempted to download multiple files automatically". How does Chrome determine when to show this message? Can I do something to reset it?
The site is loaded as an iframe within microsoft teams. But I don't think that is the issue
Fire up Chrome, click the menu icon, and then click “Settings.” Alternatively, you can type chrome://settings/
Once in the Settings tab, scroll down to the bottom and click “Advanced.”
Scroll down to the Privacy and Security section and click on “Site Settings.”
Scroll down the list of settings until you see the “Automatic Downloads” option. Click on it.
By default, the feature is set to ask permission when a site tries to download files in succession. This is the recommended behavior, but if you want to block all sites from downloading multiple files automatically, toggle the switch to the Off position.

Copying websocket payload info from chrome developer tools

How do you copy the entirety of the "frames" tab when inspecting a web socket in Chrome Developer Tools? Whenever Ctrl A, then Ctrl C, it only copies what is currently visible on my screen, not everything in the tab.
I can reproduce this annoying problem too. I will look into getting a fix for this in a future release of DevTools. In the meantime, I came up with a method of getting the data out of DevTools.
Open up DevTools in un-docked mode and navigate to the Frame panel.
Open up DevTools inspector using Cmd+Opt+I (Mac) or Ctrl+Shift+I (Windows)
Inspect the Frame panel, select the table element, and then right-click and select Copy > Copy outerHTML
Paste into your text editor and save it as an HTML page.
Open it up in the browser to view the table, which you can copy without restriction.
Update:
Before you Copy the contents of the HTML in step 3, you need to run the following code in the Console of the DevTools inspector (not the page one). The reason is that the rows in the table are only rendered when they are visible in the view port, based on size and scroll position. This explains a lot. The code below will override the __calculateVisibleNodes function to return the un-filtered list of nodes rather than reducing it to 11 items at a time.
WebInspector.ViewportDataGrid.prototype._calculateVisibleNodes = function() {
return { visibleNodes: this._flatNodesList()};
}
Note: You will need to re-open DevTools again later as this change will mess with other features.

How to block a URL in Chrome's developer tools network monitor

I am currently analysing my page connections and I want to block some tracking scripts and other external URL calls in my network monitor inside Chrome's developer tools.
I quickly want to check how the page behaves without some libraries.
Chrome itself does not provide any functions like this and the famous blocking extensions only block URLs which the user enters manually into the navigation bar.
As pointed out by #calavera.info, #iman.Bahrampour, and #Asim K T this feature is now available in Chrome 59. You can select a URL or domain to block in the Network panel. See this release note and these Screenshots where the StackOverflow logo has been blocked from this page. #iman.Bahrampour also shares two extensions below that will also do this ("HTTP Request Blocker" and "Request Blocker").
As abd3721 mentioned this is available directly within chrome DevTools (You don't need to be on canary anymore), however it is still behind a flag and in the hidden experimental features menu. As of the time of this comment, Chrome stable is on version 53.
To enable it, open this link and click the enable link under the appropriate flag:
chrome://flags/#enable-devtools-experiments
Then in DevTools open up the settings panel(F1) and click on the experiments tab.
This lists all currently available DevTools experiments but it is still in yet another hidden set of features.
Press Shift 6 times while in the experiments tab to show even more hidden features, one of them will be Request Blocking.
NOTE: These features are considered experimental and may be buggy or incomplete. Use with caution.
For blocking requests in google chrome you have 3 options:
1. Google Chrome with pattern matching:
In network tab, right click on request and then select block request URL
There is a plus sign that adds patterns for blocking requests
For example I have 7 request URLs:
http://www.test.com?userid=5
http://www.test.com?username=username
http://www.test.com?email=email
http://www.test.com?name=x
http://www.test.com?family=q
http://www.test.com?family=y
http://www.test.com?family=z
I can block requests that have a specific pattern by adding a pattern(for example the pattern *family* blocks 3 below requests):
http://www.test.com?family=q
http://www.test.com?family=y
http://www.test.com?family=z
Be careful! Because patterns are case sensitive
2. HTTP Request Blocker extension:
This extension has pattern matching for blocking requests:
Match patterns
3. Request blocker extension:
This is a useful extension that has pattern matching for blocking requests.
The most useful features of this request blocker are importing and exporting lists for using by other People.
For exporting a list and using in another computer(or future used): click on Direction down and select Export.
Open the exported list with import list button.
Good Luck
From Chrome 59 you can block specific requests from Network tab of developer tools itself.
https://developers.google.com/web/updates/2017/04/devtools-release-notes#block-requests
Right-click on the request in the Network panel and select Block Request URL. A new Request blocking tab pops up in the Drawer, which lets you manage blocked requests.
This is now achievable in Chrome 59 developer tools by blocking respective requests: https://developers.google.com/web/updates/2017/04/devtools-release-notes#block-requests. With this approach it is somehow difficult to turn off all the stylesheets, but it's easier to turn off just the most annoying ones.
As for Google Chrome 94, it's possible to exclude network activity for entire domain:
1. Go to "Network" panel of DevTools:
2. Rigth click on item of domain you want to block, click on "Block request domain" in the context menu:
3. Type "status-code:0" into "Filter" and click on "Invert" checkbox:
To manage blocked domains, press ESC button when in DevTools, and click on "Network request blocking" tab in the bottom panel:
Will changing host file help.
Your system (windows, linux, mac) all check host before requesting DNS lookup. I use it when I wan tot block some slow advertisers.
windows:
c:\Windows\system32\drivers\etc\hosts
linux & mac
/etc/hosts
* BE VERY CAREFUL TO MAKE BACK UPS *
An existing bug report is requesting this feature. You can star that issue to show support for it being added.
Well, i have been looking for an answer for this too, as I had this issue of choices by counterfeit, and nothing seemed to work for me.
But then I tried to analyze the requests and other things until I figured out, that there was this site which was loading ads onto my pages and redirecting me to advertisements. And also changing the google search bar on new tabs to some unknown search engine. I was able to temporarily block the request on one page. but after opening a new tab, the ads would appear again.
So googling for request blocker, I came up with a chrome extension "HTTP Request Blocker" and added the address which was causing all the crazy ads, has now solved the problem fully.
I hope it will be of help to you too or anyone else.
In the original question, the author states:
the famous blocking extensions only block URLs which the user enters manually into the navigation bar.
This is no longer the case. I have really enjoyed using mokku, which can intercept and mock all types of requests. You can specify what the status code should be, so it will definitely solve this problem as well as adding other functionality that is helpful. It works by another tab in the chrome dev tools. Here is a link to the extension: https://chrome.google.com/webstore/detail/mokku-mock-api-calls-seam/llflfcikklhgamfmnjkgpdadpmdplmji?hl=en

How to disable chrome extensions JS when debugging in devtools?

When I add mouse event breakpoint, devtools always jump into extension's JS.
Is there any way to point to my mouse event code directly?
The only way to disable the script (e.g. to avoid side-effects) is by disabling the extension (for instance, by using incognito mode if the extension is not enabled in incognito mode).
If you don't mind the scripts to run, but want to ignore extension code, then you can use the script blackboxing feature of Chrome's devtools.
If you never develop extensions and aren't interested in stepping through it, then open the settings menu of the devtools, click on Blackboxing and then the "Blackbox content scripts" checkbox:
If you only want to selectively ignore files, then you can also right-click on the source of the file that you want to ignore, and click on the "Blackbox Script" contextmenu option. To remove the pattern, go to the "Blackboxing" settings panel as shown before.
I think the simplest way is to open an incognito window (Ctrl-Shift-N) (or Cmd-Shift-N for mac) and debug in there, because then there will be no extensions loaded (by default).
I know what you mean by this question: when debugging, and doing something simple like pausing execution, you always find it breaks into one of the extension's codes instead of the current webpage's code.
open developer tools, then go to settings and then click on ignore list, and check the checkbox for add content script to ignore list, then add this to the ignore list: ^chrome-extension://
If you're using Google Chrome (or any Chromium-based browsers), simply run a new browser instance with a fresh user's data directory.
On Linux:
google-chrome --user-data-dir=$(mktemp -d)
This way, all extensions will be disabled without having to manually switch off/on them.
I like to use Profiles for that.
While changing into incognito mode might help you to disable most of the extensions, some of them might be allowed and still run. For example I have DarkReader and Ublock enabled in incognito mode.
My favorite workaround is to use a "Guest" profile or to create a profile that you can use for debugging. I think it is easier than creating a Framework Ignore List inside of devtools.
How to create a profile: https://support.google.com/chrome/answer/2364824
Example: My debugging profile
First off you should probably review the tutorial on how to debug chrome extensions here:
http://code.google.com/chrome/extensions/tut_debugging.html
When in doubt, you can always use the debugger keyword directly in the JavaScript code where you want to launch the debugger from, like so:
element.addEventListener("mouseover", function() {
debugger;
// some JS handler code...
});
Depending on if your JS is in a popup, background page, or in a content script, you will need make sure you launch the dev tools from the right place.
For a popup, you need to right click on the extension icon and "Inspect Popup" and then from the JavaScript console you would need to run location.reload(true)
For a background page, you need to go to the extensions settings page, chrome://settings/extensions, turn on developer mode, expand the extension in question and click the background page link.
The content script should be visible directly from the page it is loaded onto.