davemackey davemackey - 1 year ago 77
Javascript Question

Editing Built-in Chrome Bookmarks Manager Folder/Sub-Folder Auto-Expansion?

When using the the built-in bookmark manager in Chrome there is a navigation pane on the left which contains all the folders/sub-folders containing bookmarks. When one mouseovers a folder while dragging/dropping a folder/bookmark it auto-expands the folder (e.g. shows all sub-folders) after x period of time (400 ms).

I'd like to make the variable that controls how long Chrome waits before auto-expanding the folder customizable.

I found the code in Chromium that determines how long to wait before auto-expanding a folder on drag and drop in:

// src / chrome / browsers / resources / bookmark_manager / js / dnd.js

The relevant lines of code are:

* Delay for expanding folder when pointer hovers on folder in tree view in
* milliseconds.
* @type {number}
* @const
// TODO(yosin): EXPAND_FOLDER_DELAY should follow system settings. 400ms is
// taken from Windows default settings.

What I don't know how to do is to override this via an extension?

Use Case: I have lots of folders and nested folders and nested-nested folders. Oftentimes I am trying to navigate to a top-level folder but Google's hover time before kicking off auto-expand is extremely short and many times folders I didn't mean to expand end up expanding.

Answer Source

Well done with locating the relevant code for this.

Unfortunately, I don't believe Chrome extensions can access these files. This would require an API to those variables (and you'd have to rebuild the application when changing any settings).

I was able to come up with two options through some research.

Option 1

A better solution compared to an extension (especially if this is just a one-time override) would be to fork the project and edit that code for your own customized version of Chromium. Here is a guide for getting started with the code, and building/running your own version of Chromium. Maybe if you come up with a good solution to this problem, you could even submit a patch :) Even better would be to build an API to those files, and then you could create an extension.

pros: you'd just have to change one number in the code. cons: you'd have to deal with maintaining a forked version of Chromium.

Option 2

Create an Override Page

Override pages are a way to substitute an HTML file from your extension for a page that Google Chrome normally provides. In addition to HTML, an override page usually has CSS and JavaScript code.

An extension can replace Bookmark Manager: The page that appears when the user chooses the Bookmark Manager menu item from the Chrome menu or, on Mac, the Bookmark Manager item from the Bookmarks menu. You can also get to this page by entering the URL chrome://bookmarks.

Using chrome.bookmarks, you could then build a customized bookmarks page.

pros: Solution only requires an extension! cons: you'd have to build the page from scratch or find some other replication technique.

A number of extensions have achieved this method, and maybe through google searching (keywords "custom" and "manager" are helpful), you may also find a solution you like or can contribute to.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download