Prevent caching of #require'd files - greasemonkey

I use #require to load a local JavaScript file shared by some of my GreaseMonkey scripts. When I change the file, GreaseMonkey continues to use the original version and does not load the new version. How can I disable the caching of the #required file?

In TamperMonkey, file:// resources won't be cached. You should, however, enable access to file URLs at Chrome's extension management page:
The are other ways to prevent caching of #required files (source):
Increase the version number and save the script. All resources will be reloaded.
Set "Config mode" to "Advanced" in the Setting tab. Scroll to "Externals" and set the "Update Interval" to "Always". "Always" means after the resource was used, so you might need to execute/load the page twice.
You can edit the external resources using the "Edit" button.

Related

Is there a way to copy an extension from a browser to another?

Is there a way to copy an extension from a browser to another browser (both chromium based)?
In windows 10 I know the browser reads its data from this folder:
C:\Users<account_name\AppData\Local<browser>\User Data\Default
in Default there are several folders, among many:
"Extensions" and "Local Extension Settings"
which have as many folders inside as there are extensions installed and each of these folders has the extension id as its name.
So I tried copying Extensions\<id_ext> and "Local Extension Settings"\<id_ext> to their respective folders of another browser, but that wasn't enough.
Do I forget something (some other folder and\or registry key) or i's not possible to do this operation (without breaking the browser of course)?
EDIT
my goal is to have an old version of an extension fully installed in the browser (make the browser believe that it comes from the CWS) but in which I have disabled future updates (by modifying the update_url field in the manifest.json file with a fictitious address)
EDIT # 2
I will try to add two lines to better explain my purposes.
I've read something on SO and beyond, but nothing that can enlighten me about it.
My aim is to install an old version of an extension created by me
(I have the extension public key but I no longer have the private key), to block the update for a certain time and then update when I want by resetting the update_url field in the manifest.
Thanks

Python Windows Explorer Force Refresh

I have code, but it doesn't do what I want. I'm trying to delete thumbnail cache via Python script. If I have cache and explorer's open, some of the .db files won't delete because they're in use by explorer. Anyway, in my experimenting, the only way to do it is to change the advanced folder setting for displaying icons/thumbnails, and then restarting explorer. I can change the setting via script in the registry and then restart explorer. BUT, restarting explorer halts the script. So, I don't know. I also tried changing the setting and then sending the WM_SETTINGCHANGE message via SendMessageTimeout(). That didn't do the trick.
So, anyone have any idea how to unlock files (that are safe to delete) from explorer (this could also pertain to other in-use files) without restarting it? Also, I understand this is a sort of dumb project, but I have my reasons for doing it and it's what I want to do.
If I have cache and explorer's open, some of the .db files won't
delete because they're in use by explorer.
Because thumbcache.dll still has an open handle to the local thumbs.db file and does not currently implement a mechanism to release the handle to the file in a more dynamic and timely fashion.
They are only generated for compatibility with outdated applications, and are not required for Windows operations.
To work around the issue, enable User Group Policy setting for "Turn off the caching of thumbnails in hidden thumbs.db files":
Refer: http://support.microsoft.com/kb/2025703?
Also, you can directly edit the registry. Refer:Let me fix it myself
Related: "The action can't be completed because the file is open in Windows Explorer"

Leverage browser caching - I have this enabled but GT Metrix not showing it

I have Leverage browser caching configured on my site via the .htaccess but when I run a performance check on GT Metrix or Google Page Speed - they both say that this is missing and needs to be enabled - any suggestions?
All of the links that it is flagging are external - Google Tag Manager, api.feefo.com, Google tag manager etc.
You cannot control the caching on external links, the domain they are served from sets the cache times.
If you really want to do it (no business sense in it, but just for trying to get no errors / advisory items) then you can use the method I use:-
use cURL or similar to download the file every 4 hours.
cache that file on your server
serve the local copy of that file so you can control the headers.
Don't forget to set up cache busting on the local copy so that every time you download the latest version from the external host and it is different you can override the cached file.
As stated, ignore this item if it is only external resources, you have done everything correctly it is just part of the diagnostic tools.

Run Chrome Extensions using command prompt

Is it possible to run a chrome extension from command line?
I need to automate the process for my software, and my software will need to run that extension with a particular parameter.
I am using a Chrome Extension 'APK Downloader' by Yogi. The Extension works like this:-
"If a page contains any .apk file link, then when I click on the extension's icon on the address bar, it starts direct download of that .apk file"
Now, I have my software that needs some .apk file to download [The software will have the package name of the .apk file to be downloaded, which is used by the extension to generate a download link]. It will be an automatic process. So, I need to know if it is possible to pass a parameter to the extension automatically, and make the extension to work without clicking on it.
Is it possible to do so??
Unpacked extension can be loaded using the --load-extension= flag.
What I usually do is chromium --user-data-dir=/tmp/someuniquedirname --load-extension=path/to/extension --no-first-run.
The --user-data-dir= flag is used to specify a non-default user data directory, to minimize conflicts between your existing browser profile and the test directory. You can omit this flag if you want to use your default user profile.
The --no-first-runflag prevents the first run UI from showing up (e.g. the bubble that explains how to use the omnibox, and a "Getting Started" page that opens in a new tab).
You can load multiple extensions by separating the paths by commas, e.g. chromium --load-extension=path/to/one/extension,path/to/another/extension.
I have published some shell scripts and a convenience extension to speed up (manual) testing of Chrome extensions. Take a look at https://github.com/Rob--W/extension-dev-tools/tree/master/chrome.
it helps to open extension normally and after that hit F12 (dev tools) to see actual url...
having that i can, for example load "Selenium IDE" chrome extension as
(run from command prompt)
"C:\Program Files (x86)\Google\Chrome\Application\new_chrome.exe" chrome-extension://mooikfkahbdckldjjndioackbalphokd/index.html
on a mac:
osascript <<EOD
set theURL to "chrome://extensions/"
tell application "Google Chrome"
if windows = {} then
make new window
set URL of (active tab of window 1) to theURL
else
make new tab at the end of window 1 with properties {URL:theURL}
end if
activate
end tell
EOD
Question answered here:
https://superuser.com/a/979678

Making a Windows Installer communicate with a Chrome extension without NPAPI

I have a windows application which installs a Chrome extension via the windows registry. I wish for this application to generate some one-time information for Chrome to read based on information typed in by the user during the installation process.
Assuming I am not using NPAPI in the Chrome extension, is there anywhere the installer can place information such that the extension will see it?
Edit: I also wish to launching chrome at the end of the installation.
Another way you can pass information to an installed extension from outside of Chrome is to have a page with your extension that you then open Chrome too and pass the info in the hash...such as....
chrome.exe "chrome-extension://emcggffhhapbbkcodabdliakappfibcf/showHash.html#info"
Problem with this method is your installing the extension using the simple registry method (Im guessing) and not using the Policy method. With the Policy method you can force an install and it will happen even if Chrome is allready open (where as according to the docs the simple method happens the next time Chrome is opened). Downside to this is you will have to make an uninstaller yourself as you cant uninstall an extension from Chrome that is installed with this method. Im also not sure how quick/often it will be before the extension is installed (couldnt find it in the docs and too lazy to try it ;)) and youd need to make your installer wait a bit for it to be installed....
http://www.chromium.org/developers/how-tos/adding-new-policies
http://dev.chromium.org/administrators/policy-list-3#ExtensionInstallForcelist
http://dev.chromium.org/administrators/policy-templates (says where in the registry to add them)
Another possible method could be to pack the extension at install time and add a file with the info that the extension could read. Problem with this method is that the extensions ID would change (might not be a problem for you?) or youll have to include the PEM in your installer which you probably dont want to do....
chrome.exe --pack-extension="C:\simple-example" --no-message-box
Many people wish there were an event firing on extension installing.
There's a workaround, not elegant way to send info to the browser from outside: launch chrome asking to open an url.
I use it with a local html file. My application execute a command line like:
"pathToChrome\Chrome.exe" "file://pathToHtmlFile/myFile.html?param1=value1&param2=value2"
The info I pass are the page's parameters.
The catch is that this page is read by the extensions in one of many ways:
You can write a content script this page will fire
You can put some javascript on this page to write down the parameters as cookies, for the extension to read in the future (without calling the extension at this time)
It hasn't to be a local page. If your page is on a server, it can save the parameters in the server, ir it worthy.
It hasn't to be even your page. You can call any page on Internet, but beeing sure it will fire your content script extension, and it will read your "customized" parameters.
Instead of communicating through the windows registry, you can create a WebSQL from the installer and from the extension read the data from there.
You will need to a bit of research about how to this, but this is possible. the steps should be:
The installer will create the database and register to chrome (maybe with the Databases.db)
The extension will use openDatabase to create a connection to the database
The extension will do a transaction and read the needed file.
Another option is to add file to the crx for example "installer_info.json" and do an AJAX request from the extension to the "installer_info.json" file.
There is no formal way for doing this things, little research and you will have a way.

Resources