Replacing Javascript file in Google Chrome cache - google-chrome

I would like to replace a javascript file in my Google Chrome cache such that when I reload a website it will run my modified script. I could do a whole setup with puppeteer instead but it would be just way easier if I could just replace the cached file. However, I cannot seem to locate my cache or any info on wether this is possible since the data might be encrypted or encoded. Alternatively is there an extension that would let me do this?

You can replace a JavaScript file in your Google Chrome cache by following these steps:
Open Chrome and press F12 to open the developer tools.
Go to the "Application" tab in the developer tools and select "Cache" from the left sidebar.
Find the JavaScript file you want to replace in the cache and select it.
Right-click on the selected file and choose "Delete" to remove it from the cache.
Refresh the website to reload it and run your modified script.
To run the modified script, you can use the "Sources" tab in the developer tools to open the file and paste in your changes.

Related

Chrome allow automatic download

I have a HTML file with javascript which runs locally on my pc. (Not using server!)
When the program runs in error, it creates a log TXT. I am using 'console.save' script.
My problem is that chrome doesn't automatically downloads the second txt, because it asks for permission to download. If I give permission it works but only until I refres the page. After refresh it won't work.
I tried in "chrome://settings/content/automaticDownloads" to give permission but it does not work. It's not an URL, it's a "file:///C:/index.html".
In the settings I have only 2 options. To deny the download or to ask for permission. There is no option to allow all downloads.
Is there any way to allow it?
In Chrome, go to this url:
chrome://version/
There you can see the Profile path. Go to that location. By default it is:
C:\Users\YOURUSERNAME\AppData\Local\Google\Chrome\User Data\Default
Here, find the Prefrences file. Before editing, close Chrome. Then edit the prefrences file with any text editor and add this:
"default_content_setting_values":{"automatic_downloads":1}
Now Chrome will not ask for permission when it want's to automatically download files.

Refresh Chrome policies programmatically?

I wrote a Chrome extension, that uses local storage.
When I open chrome://policy/ in the browser I can see my extension's data according to the its ID, however, when I change the value manually in the registry it DOES NOT get updated automatically. Instead I have to click on the "Reload policies" button.
My extension uses this data and has to be updated.
How can I refresh chrome policies from my code? (As if the user would click on the "Reload policies" button.)
Thanks!
For Windows, even if you're just managing the information in the registry and not via GPO, you force the updates to be reflected in Chrome with:
gpupdate /force

Why are some files in Network but not in Sources?

I, using a Chrome browser, am troubleshooting a node.js web application on a page generated by Jade.
Most of the script files included in the Jade file appear in the Sources tab in Chrome F12, ie under the tree beginning with Top. However, there is one particular script file that I see has been loaded under the Network tab (Chrome F12) but does not appear in the Sources tab. As a result I am unable to put breakpoints in that script.
That script file was included with a simple append to a block. But in the Network tab, it was shown called with a query string parameter of a long number, eg emoji.js?123232323.
What could be happening and how do I fix it?

Dev tools Network Tab, open script in Sources tab?

In Chrome Dev Tools, when viewing the Network tab, is it possible to select a script and open it in the Sources tab? Double-clicking the script opens it raw in a new browser tab.
Because the Sources tab organizes all assets by their source domains (along with folder paths), it can be time consuming to locate a particular script, if you don't know immediately where it came from. You have to switch back and forth between Network and Sources, taking note of the domain and folder path in the script's header and then trying to dig through all the source domain's and subfolders until you locate the script.
It seems like there should be some obvious way of opening a script in the Sources tab from the Network tab, but I don't see how. You appear to have to manually dig to find it.
EDIT
This feature is now available in Chrome Canary, and should be available in stable Chrome in a few weeks.
As far as I know this is not possible right now. I think it's a good idea though, so I reported it for you.
The quickest way, I can think of, to open a script from the network tab in the sources tab is to:
copy/memorize name of the script from network tab,
go to the sources tab,
open file search (cmd+p / ctrl+p),
enter name of the file you are looking for.

How would I go about developing a file handler for Chrome and/or Chromium?

I would like to develop a browser plugin/extension (I'm not sure how they differ) for a particular (possibly new) file type. To be very explicit, I would like to visit a file, "foo.org", using my browser in something like Drop Box or Google Drive and have the browser treat the file as Emacs would treat an org-mode file. Eventually I would like to develop a full Emacs plugin/extension and be able to configure the browser to handle files with this plugin/extension based on the file extension or a file grokking heuristic.
Any solution that I develop will allow the editing to take place directly in the browser's tab area, i.e. a seamless solution (as opposed the useful but seamy Edit with Emacs solution referenced below). In the same way that Chrome recognizes a spreadsheet or word document and invokes the appropriate Google Docs tool, I would like to get an Emacs-lite editor handle the foo.org file. Another way to ask the question is: how do Google Docs tools get invoked within Chrome and perform the associated editing task. And are these tools open source?
You should consider building on Ymacs which is an Emacs-like editor in the browser.
For browser extensions, there is an experimental downloads api. However, it doesn't let you monitor downloads at the moment. This is planned for the future:
In the future, you will also be able to monitor and manipulate downloads.
However, you can probably just use some JavaScript and replace all links to *.org files with links that open in a tab running Ymacs. This should have the same effect--clicking a *.org link will open it in a new tab.
Take a look at content scripts and the tab api for documentation on how to inject a script into every page and how to open new tabs.
Take a look at Edit with Emacs , it should help you get (at least) part of the way there.