I am attempting to set various Google Chrome preferences via a script (on both OS X and Windows). I can successfully set a number of preferences, and add bookmarks, by editing the Preferences and Bookmarks json files in the user's Application Data folder. However, when i attempt to set a new default search provider, the browser automatically reverts to Google search.
The default search provider node in the Preferences file looks like this:
"default_search_provider": {
"enabled": true,
"encodings": "UTF-8",
"icon_url": "http://www.google.com/favicon.ico",
"id": "2",
"instant_url": "{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&ie={inputEncoding}&ion=1{searchTerms}&nord=1",
"keyword": "google.com",
"name": "Google",
"prepopulate_id": "1",
"search_url": "{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}sourceid=chrome&ie={inputEncoding}&q={searchTerms}",
"suggest_url": "{google:baseSuggestURL}search?client=chrome&hl={language}&q={searchTerms}"
}
In order to add my desired search provider, I've simply added it manually (via the wrench menu), viewed the effect of this action on the json file, and then written a script to mimic these changes. However, when I change it via a script, the default search provider is used for the first search, but then resets the next time chrome is started. What am i missing here?
as mentioned, you should edit the 'Web Data' file, which is an sqlite database.
To add a search engine, add an entry to the 'keywords' table.
To change the default search engine, edit the 'Default Search Provider ID' value inside the 'meta' table.
If you want to change the default search provider in Google Chrome you have to modify 'Web Data' file wich is an SQLite file.
On my computer the location where you can find the file is C:\Users\daniel\AppData\Local\Google\Chrome\User Data\Default(Windows7).
See the content of file with SQLite Database Browser; you can find one here.
Despite everybody here suggesting to write to Chrome's Sqlite DB, the same can be achieved via JSON based config files (as noted above by https://stackoverflow.com/users/49572/andreas-huber).
The relevant documentation can be found here:
https://www.chromium.org/administrators/policy-templates
https://www.chromium.org/administrators/linux-quick-start
https://www.chromium.org/administrators/policy-list-3#DefaultSearchProvider
For Chrome on Linux putting something like this into /opt/chrome/etc/policies/recommended/duckduckgo.json shoud get you started:
{
"DefaultSearchProviderEnabled": true,
"DefaultSearchProviderName": "DuckDuckGo",
"DefaultSearchProviderSearchURL": "https://duckduckgo.com/?q={searchTerms}"
}
On Windows and OSX and with Chromium the places to set this are different, but are all documented under the above given URLs.
A solution that is working for Chromium and Chrome on Ubuntu can be found here:
https://github.com/andreashuber69/os-setup/blob/master/common/reset-browser-preferences
Besides setting the default search provider, the linked script further customizes Chromium/Chrome to my liking. For Chrome, the part relevant to the question goes like this:
# Modify the preferences relevant to the default search provider
cat ~/.config/google-chrome/Default/Preferences | jq '.default_search_provider_data.template_url_data={ "keyword": "duckduckgo.com", "short_name": "DuckDuckGo", "suggestions_url": "https://duckduckgo.com/ac/?q={searchTerms}&type=list", "url": "https://duckduckgo.com/?q={searchTerms}&t=canonical" }' >adapted-preferences.json
mv adapted-preferences.json ~/.config/google-chrome/Default/Preferences
This simply adds a new entry to the list of search engines and sets it as default. If you want to select an existing one, things are little more complicated (see script for details). The above requires the package jq, which is not present out of the box on Ubuntu.
Contrary to other posts, it seems no longer possible to set the default in the meta table. It must be done through the Preferences file as shown above.
Related
Whenever I open chrome, I want:
All my previous pages are there
Another page, with a custom URL, is there. (With the possibility of me setting it to be chrome://newtab.)
Is this possible?
Is there a way that on open specific set of pages, I can add previous pages?
I have tried looking. The closest thing I could find was this. This is not exactly what I wanted.
I would like a simple and easy way of doing this. (I don't mind extensions but I couldn't find any.)
I want this to be done without any input from me every time. So no CtrlShiftT please.
Thank you in advance.
If you need to automate Chrome GUI, it's possible using pywinauto. My student wrote an example dragging file from explorer.exe to Google Disk opened in Chrome. There are some tricks used here.
test_explorer_google_drive.py
Chrome requires command line parameter --force-renderer-accessibility to enable MS UI Automation support in Chrome. So if you're starting Chrome it should work for you. If you're trying to connect to existing Chrome window this might be a problem.
Need to use backend='uia' explicitly for pywinauto.Application object. See the Getting Started Guide for more details, core concept and other useful things.
The relevant part of the mentioned script:
from pywinauto import Application
chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
# start Chrome
chrome = Application(backend='uia')
chrome.start(chrome_dir + ' --force-renderer-accessibility --incognito --start-maximized <URL>')
# wait while page is loading (up to 10 sec.)
chrome['<Tab caption>'].child_window(title_re='Reload.*', control_type='Button').wait('visible', timeout=10)
the details of this may depend on your operating system but on windows I can access a "master_preferences" file in C: > Program Files > Google > Chrome > application.
the contents of the file looks like:
{
"homepage": "http://www.google.com/",
"homepage_is_newtabpage": false,
"distribution": {
"suppress_first_run_bubble": false,
"import_search_engine": false,
"import_history": false,
"do_not_launch_chrome": true,
"make_chrome_default": false,
"verbose_logging": false,
"ping_delay": -60
},
"sync_promo": {
"show_on_first_run_allowed": false
},
"session": {
"restore_on_startup": 4,
"startup_urls": ["http://www.google.com/"]
},
"first_run_tabs": ["http://www.google.com/", "http://welcome_page"]
}
You can see there are settings for restore_on_startup
and startup_urls under the "session" heading
try editing those settings so the look like this:
"restore_on_startup": 2,
"startup_urls": ["http://www.google.com/", "http://www.theurlyouwant.com"]
You may not be able to configure these settings on your work or school computer as it requires administrator privileges. And also if you're not familiar with JSON pay especial close attention to the syntax (commas, quotation marks etc) I've used in my examples.
I don't know if this will help, it's certainly not as technical a response as everyone else, but I use the OneTab Chrome extension to do some of the stuff you're talking about.
I have a handful of pages saved to it, and I click the Restore All button and they all load in. You can save groups of tabs, and lock those groups so they're not easily deleted on accident, and name groups of saved tabs as well. I think it's pretty helpful, but it might not be exactly what you need/are looking for. Hope it helps though!
TL;DR: SourceTree for Windows recently added the "commit text links" feature, but it appears that the replacements must be set up per-repository. Is there a way to apply them globally or a config file that could be modified programmatically to set them?
Long version: The "commit text links" feature looks incredibly useful but I have a bit of a problem: We have about a dozen JIRA projects and over 25 repositories that each of them could be related to (none of them are 1-to-1 mappings). While I could set up a single regular expression to match each of the JIRA projects, it's a bit much to ask all of my developers to set it up through the UI for each and every repository. To really take advantage of this I ideally need to be able to give them instructions on a single file to modify or I need to generate a setup script that I can distribute to our developers.
Is there a config file that this setting is saved in? I was expecting to see it in something like .hg/hgrc but I couldn't find anything. I also couldn't find any relevant settings in the SourceTree Program Files folder.
Alternatively, is there a global or default setting that can be applied across all repositories? That plus the regex version could make setup significantly less painful if still manual.
Thanks!
(Note: I'm in version 1.3.3.0 of SourceTree for Windows, which I believe is the most recent stable version)
May be a bit late, but I've found a relatively easy way to do this.
Underneath your .hg/.git folder within your repository should exist a file called 'sourcetreeconfig.' This is where the links live and can be manually edited.
First make sure that you have closed all of the existing repository tabs within sourcetree, and additionally close sourcetree afterwards. Then, (assuming you have already configured a repository) copy the block from the respective repository's sourcetreeconfig and do a replace across all of your sourcetreeconfig files. This would be if you have multiple tied to the same project. It should be relatively easy to throw something together that can configure for different projects, just replace the url/project within the config.
Upon reopening sourcetree, each of your repositories should reflect this change.
This was performed using version 1.6.5.0 of sourcetree.
Programmatic Solution
Here in late 2019, the ability to globally configure commit text links in Sourcetree 3.2.6 for Windows still does not exist. Since this question was one of the few hits with a decent answer, I figured I would add an automated solution to the answers. I'm not a programmer, and I know the RegEx isn't the best, but this simple PowerShell script I cobbled together gets the job done. Make sure Sourcetree is closed before you run the script.
Copy the sourcelinker script into a Notepad++ or similar text editor application.
In order get the specific string for your setup, configure one of your Git repos with one or more commit text links specific to your organization.
A. Launch Sourcetree, select a Git repo, and click Settings.
B. In the Repository Settings window, click the Advanced tab.
C. In the Commit text links area, click Add.
D. From the Replacement type drop-down list, select Other.
E. Enter the Regex pattern and Link to URL for your specific setup, and click OK.
F. In the Repository Settings window, click OK.
G. Close Sourcetree.
Navigate to the .git sub-directory of the repo you configured, and open sourcetreesonfig.json.
Copy everything starting with "CommitTextLinks": [ through the closing bracket and comma ],. For example:
"CommitTextLinks": [
{
"$id": "11",
"LinkType": 99,
"Regex": "[fF][bB][#\\s]*(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[fF][bB][#\\s]*(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
}
],
Paste the copied content into your sourcelinker script between the single quotes that follow $New1 =.
Save the script as sourcelinker.ps1.
Copy sourcelinker.ps1 to the root folder where your Git repos reside.
Right-click the script, and select Run with PowerShell.
Launch Sourcetree, and check the Commit text links for your other Git repos.
Sourcelinker script
This script example contains Regex examples that link to Fogbugz and handles variations such as:
case12345
fb12345
bugzid12
Script
# Sourcelinker script
$InputFiles = Get-Item ".\*\.git\sourcetreeconfig.json"
$Old1 = '"CommitTextLinks": null,'
$New1 = '"CommitTextLinks": [
{
"$id": "9",
"LinkType": 99,
"Regex": "[bB][Uu][gG][sSzZ]\\s*[Ii][Dd]s?\\s*[#:; ]+(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[bB][Uu][gG][sSzZ]\\s*[Ii][Dd]s?\\s*[#:; ]+(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
},
{
"$id": "10",
"LinkType": 99,
"Regex": "[cC][aA][Ss][Ee]+\\s*(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[cC][aA][Ss][Ee]+\\s*(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
},
{
"$id": "11",
"LinkType": 99,
"Regex": "[fF][bB][#\\s]*(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[fF][bB][#\\s]*(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
}
],'
$InputFiles | ForEach {
(Get-Content -Path $_.FullName).Replace($Old1,$New1) | Set-Content -Path $_.Fullname
}
Solution inspired thanks to suggestion by Andrew Pearce from this thread.
Where does GM_setValue store the data to in chrome. I've tried to determine where the data is going but couldn't figure it out. I monitored with process monitor and saw that when I stored a value chrome was updating a chrome_iwoeoiifoi2h3iofhufsdfnvdf type of file and I opened that up with an sqlite browser but the data was not there. I've looked at all the recently modified files trying to find the data but could not find it.
Latest chrome/TM.
In Tampermonkey, GM_setValue() data is stored in a LevelDB database that can be found in the User Data Directory tree.
Once in Chrome's "User Data Directory" (EG: C:\Users\USER_JOE\AppData\Local\Google\Chrome\User Data\Default\),
navigate to the Local Extension Settings\dhdgffkkebhmkfjojejmpbldmpobfkfo folder.
(gcalenpjmijncebpfijmoaglllgpjagf for the Tampermonkey Beta.)
There you will find a LevelDB database, usually named CURRENT. You can manipulate it with tools like LevelDB JSON, but external support for LevelDB currently appears to be spotty and I did not find any working tools for Windows yet (might have to compile your own).
You can also use the Chrome Storage Area Explorer extension to explore the data.
As of Tampermonkey 4.3.6, you can see an individual script's data with the Storage tab in the built-in script editor: (if the 'Storage' tab is not visible, edit Tampermonkey Settings > General Config mode > Advanced)
OLD, Pre November-ish 2015:
Before, about November 2015, data was stored in a Web SQL database in databases\chrome-extension_dhdgffkkebhmkfjojejmpbldmpobfkfo_0.
Once you have navigated to the correct folder, you will typically see two files. On my machine, they are currently just named 4 and 6. These are both SQLite files (the backend for Chrome's Web SQL implementation) and can be inspected with a SQLite viewer/utility.
The (normally) larger file, 6 on my machine, is a somewhat disturbing list of 94-thousand userscripts! I'm not sure what purpose it serves, but haven't investigated it much.
The smaller file (initially, at least), 4 on my machine, is where all the information about/for your userscripts is kept. This includes any data set by GM_setValue().
For example, if I install and run this userscript:
// ==UserScript==
// #name _GM_setValue demo
// #match https://stackoverflow.com/questions/*
// #grant GM_setValue
// ==/UserScript==
GM_setValue ('foo', 'bar');
And then I inspect the `config` table in file `4`, I will see four entries like this:
[![DB entries for sample script][8]][8]
The one you want is the `#st` row. Notice how it has the `GM_setValue` data encoded? :
The code completion feature works really well when I type Java code, but I've recently made a build system for Modula-2, and while the auto-complete works when I press ctrl+space, it doesn't suggest the words on it's own. I have to hit ctrl+space every time, which (kind of) defeats the purpose.
I realize that modula-2 is not a very popular language, but sublimetext has a nice feature which remembers every word the user writes, and uses it in the code-completion. This is why the ctrl+space combo works in the first place. Does anyone know how to enable the suggestions?
What triggers the pop up is controlled by the auto_complete_selector setting. You will need to add the proper scope to that. If you are not using a syntax highlighter for those files, I believe this will apply the source scope to the file, which will then lead the pop up to show.
{
"name": "Modula-2",
"scopeName": "source.modula-2",
"fileTypes": [""],
"patterns": [
],
"uuid": "f8005a03-62cf-460b-84be-1184508464ed"
}
This is the JSON form, you can use PlistJsonConverter to convert to a plist. Then save that as a .tmLanguage file in the packages folder, probably the User Directory, or maybe a Modula-2 directory if you have other stuff associated with those types of files.
You should try Modula-2 Language Sintax it is a new package. You can install it using Package Control or simply by git clone git://github.com/harogaston/Sublime-Modula-2.git
I'm working in a project which involves using IndexedDB.
As I'm begining to know this technology, I need to be able to delete an indexedDB by hand so I can start over.
I found the way to do it in Firefox, but I can't find the way for Google Chrome.
I tried deleting the content of this folder (I'm using Mac):
{home}/Library/Application Support/Google/Chrome/Default/IndexedDB
but it seems Chrome stil have the DB anywhere so I can't start over.
I've had success running the following in Chrome:
indexedDB.deleteDatabase('DB NAME')
In theory, all you need to do to delete an IndexedDB in Chrome is:
In Chrome, go to Options > Under the Hood > Content Settings > All cookies and Site Data > find the domain where you created the IndexedDB
Hit either the "X" or click "Indexed Database" > Remove
In Windows, the file is located here:
%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\IndexedDB
On Mac, do the following:
In Chrome, go to "Settings" (or "Preferences" under the Chrome menu)
Click "show advanced settings" (at the bottom of the page)
Go to "Privacy" > "Content Settings" > "All cookies and Site Data" > find the domain where you created the IndexedDB
Hit either the "X" or click "Indexed Database" > Remove
On Mac, the folder is located here:
/Users/[USERNAME]/Library/Application Support/Google/Chrome/Default/IndexedDB/
On Linux, the folder is located at:
/home/[USERNAME]/.config/google-chrome/Default/IndexedDB/
Alternarive is to do it in the developers console, using this command:
indexedDB.deleteDatabase("databaseName")
In Chrome webkit you can use webkitGetDatabaseNames which returns all database names
With this code, you can delete all local indexedDB:
window.indexedDB.webkitGetDatabaseNames().onsuccess = function(sender,args)
{
var r = sender.target.result;
for(var i in r)
indexedDB.deleteDatabase(r[i]);
};
To remove all Chrome IndexedDB databases run the following in OSX terminal emulator.
rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default/IndexedDB/*
Now restart your browser and that's it.
Because I need to purge IndexedDB databases very often, I have set up an alias in my ~./bash_profile.
alias purge-idb="rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default/IndexedDB/*"
Chrome -> Inspector Window -> Application -> look at left hand menu -> Storage -> IndexedDB
You have to be on your application's page though. Also I think Safari expires IDB data after 7 days or something.
write this code segment in console
window.indexedDB.deleteDatabase(<your db name>)
To delete an IndexedDB from the OS X version of Chrome:
1) In Preferences, show Advanced Settings then click the "Content Settings" button under the "Privacy" section.
2) In the "Content Settings" popup, click the "All Cookies and Site Data" button under the "Cookies" section.
3) In the "Cookies and site data" popup, use the "Search Cookies" textbox to look up the domain that is the source of the IndexedDB.
4) Click on the domain entry in the list.
5) Click on the "indexed database" tag listed under the domain.
6) Click on the "Remove" button in the drop down detail for the indexed database.
Chrome Developer tools now have an option to delete all databases for an app, under "Application/Clear Storage".
In Debian GNU/Linux directory
/home/[username]/.config/google-chrome/Default/IndexedDB/chrome-xxx.indexeddb.leveldb/
contains regular files (for example):
000003.log, CURRENT, LOCK, LOG, MANIFEST-000002
It's not possible to delete IndexedDB database (as opposed to stores and indexes) programmatically.
As for manual workarounds, this post details the location of the database on Windows systems for Firefox and Chrome.
Update: Thanks to developer Joshua Bell, Chrome implements an off-spec (but insanely useful) deleteDatabase method on the window.indexedDB object. Here's the crbug that landed this patch. Moreover, in newer versions of IE, you can delete databases via a settings panel.
This is maybe overkill for your specific question, but I kept ending up here in my struggle to delete my idb.
My solution in the end was based on mozilla's documentation, but required that I first close the database.
For me, in Javascript, the code looked like this:
my_db_instance.close(function(e){console.log(e)});
var DBDeleteRequest = indexedDB.deleteDatabase("my_db_name");
// When i had the base open, the closure was blocked, so i left this here
DBDeleteRequest.onblocked = function(event) {
console.log("Blocked");
};
DBDeleteRequest.onerror = function(event) {
console.log("Error deleting database.");
console.log(event);
};
DBDeleteRequest.onsuccess = function(event) {
console.log("Database deleted successfully");
};
In order to complete #Judson's answer, based on #fullstacklife's comment; for deleting IndexedDB in chrome using javascript you should:
let currentIDB = indexedDB.open("DB_NAME", DB_VERSION_INTEGER);
currentIDB.onblocked = function(){
//
};
currentIDB.onerror = function(){
//
};
currentIDB.onsuccess = function(){
var idb = currentIDB.result;
idb.close();
indexedDB.deleteDatabase("DB_NAME");
};
To delete IndexedDB in Chrome on Android:
Settings
Site settings
Data stored
Search needed site and press
Delete stored data
(You cannot delete IndexedDB via Settings -> Privacy and security section, what is quite misleading...)
Alternatively, use your web application in a new incognito window, and close it when you're done: database deleted.
In chrome OSX- /Users/user/Library/Application Support/Google/Chrome/Default/IndexedDB
Firefox OSX - Users/user/Library/Application Support/Firefox/Profiles/4zaemxcn.default/indexedDB
You just need to make visible the library folder. All of the files are stored in folders(which are called as domain name) and the files use hash, but you can figure out the name of database from it.
You can delete data from IDB because it is a client side database and all of the data is stored locally.
In windows, you can manually delete the whole IndexedDB databases by locating the IndexedDB directory for the browser and deleting it
For Chrome:
C:\Users\user-name\AppData\Local\Google\Chrome\User Data\Profile 1\IndexedDB
You can delete every folder which clears up the indexedDB. You can start over now.
I needed to get rid of an indexedDB in Chrome. So I search for this lousy thing called "email assistant" on my computer using MasterSeeker. Found the thing in a bunch folders that were indexedDB in Chrome. It seemed too easy that I just delete those files. I looked up how, and ended up here. I went to chrome settings with my Windows 10 PC. I just gave it a shot at trying to clear the browsing data. Presto - all those files disappeared from indexedDB, including that dreaded "email assistant" crapola. Now when I look in the indexedDB folder all I see that has reappeared is https_mail.google.com_0.indexeddb.leveldb - which looks like a safe non-irritating thing.
//By for loop
const deleteAllDBs=async()=>{
const existingDBs=await indexedDB.databases()
for (let i = 0; i < existingDBs.length; i++) {
indexedDB.deleteDatabase(existingDBs[i].name)
}
}
//By forEach loop
const dbs = await window.indexedDB.databases()
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) })
Since most of the answers not mentioned how to find the db names:
Open the site you want db to be cleared.
Press F12 in Chrome, select console regime.
Type indexedDB.databases().then(res => console.log(res)) to learn database names used by this website (open the result with interactive console, find the name).
Finally, as mentioned above, execute in the console indexedDB.deleteDatabase('<your database name>').