• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    JavaScript
  • Created about 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A WebExtension which can display/remove duplicate bookmarks or empty folders

bookmarkdupes

(C) Martin Väth [email protected], [email protected]

This project is under the GNU Public License 2.0.

A WebExtension which can display/remove duplicate bookmarks, empty folders, or descriptions

Available on AMO here: https://addons.mozilla.org/firefox/addon/bookmark-dupes/

After installing bookmarkdupes, the usage is rather simple:

To open bookmarkdupes, click the extension symbol (duplicate stars) or use the link in the options page of the extension. Do not enable “Expert Mode” (unless you fully understand the consequences, see separate section). Then select what you want to display:

  1. Bookmark duplicates
  2. Empty folders
  3. Non-duplicate bookmarks
  4. All bookmarks

After this, you will be offered the list of bookmarks with checkboxes; in case 1 the numbers indicate the order in which matching bookmarks were added according to the internally stored date. There are also buttons to select/unselect convenient sets of checkboxes.

Finally, there are buttons to remove the selected bookmarks in cases 1-3 or to strip the descriptions of the selected bookmarks in case 4. (The latter has some side effects, see section Known Bugs).

Be aware that removing bookmarks or stripping descriptions is irreversible! It is recommended to make backups of your bookmarks first!

Currently, there is no working version of the extension available for android (see section Known Bugs).

Important

When you reorganized/added/removed bookmarks, make sure to update the displayed list (by pressing the corresponding button) before removing bookmarks or stripping descriptions! In particular, stripping descriptions with an outdated list will move the corresponding bookmarks to their previous location in the bookmark menu!

Permissions

The extension requires the following permissions for these reasons:

  1. “bookmarks” to read/modify bookmarks
  2. “storage” to store/restore the customized rules in expert mode. Unfortunately, “storage” is not one of the optional permissions which might be required only if that feature is actually requested by the user, see https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/optional_permissions

Expert Mode

When selecting the checkbox for expert mode, details can be configured to ignore certain bookmarks when calculating the list or under which cases bookmarks are considered to be dupes of each other.

In non-expert mode, two bookmarks are considered to be duplicates of each other if their URL coincides. In expert mode there are custom rules by which the URL which is actually used for comparison is to be modified. The details are as follows.

For every bookmark the rules are applied in the given order. There are 2 types of rules: Filter rules and URL modification rules (there are also disabled rules which are only listed but have no effect).

For both types of rules 4 regular expressions can be specified which are used to determine if the rule applies: If the corresponding regular expression is nonempty, the corresponding condition must be satisfied or the rule will not apply. (In the case of filter rules, at least one of these 4 regular expressions must be nonempty or that filter rules will not apply either.)

The 4 regular expressions refer to the bookmark's name or url, respectively, and the regular expressions must either match or not match, respectively.

  • The term “regular expression” refers to a javascript type regular expression as described e.g. in https://wiki.selfhtml.org/wiki/JavaScript/Objekte/RegExp or https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
  • The bookmark's name refers to the full bookmark path as it appears in the browser with folder names separated by the null character. For instance, if you have in “Bookmark Menu” a folder “Collection” which contains your bookmark "Example", the bookmark's name becomes Bookmark Menu\0Collection\0Example (where \0 denotes the null character which can be matched by the regular expression with \0 or \x00).
  • The bookmark's URL refers to the bookmark URL after possible modifications by previous modifier rules.

If a filter rule applies, the corresponding bookmark is ignored, i.e., it will not be considered as a duplicate and will neither appear in the list of empty folders nor of all bookmarks.

If a URL modification rule applies, a text replacement will occur: All parts matching a specified regular expression are substituted by a replacement text (which might be empty). The rules for this correspond to the javascript String.prototype.replace function with the global modifier, see e.g. https://wiki.selfhtml.org/wiki/JavaScript/Objekte/String/replace or https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/replace

In particular, the replacement text can contain symbols like $& or $1 to refer to the whole matched text or to the match of the first brace in the regular expression, respectively.

The following 5 replacement texts have a special meaning which goes beyond the standard javascript replacement rules.

Note that this special meaning is only active if this is the full replacement text. In other words, to get the special meaning, the replacement text must not contain anything else than these 4-6 characters. (This does not really restrict the functionality, because one can combine several rules to work around that limitation if necessary.)

  1. \L$& is the match in lower case.
  2. \U$& is the match in upper case.
  3. $URL is the url before any other rules have been applied.
  4. $NAME is the bookmark's full name/path with folders separated by the null character, e.g. “Bookmark Menu\0Collection\0Example”
  5. $TITLE is the bookmark's title without the path; for instance, for the bookmark name “Bookmark Menu | Collection | Example” it is “Example”.

Cases 3-5 can be preceeded or followed by $$& to prepend or append the match.

Examples for special tasks which can be done in Expert Mode

Task

  1. Consider two bookmarks as duplicate if their URL differs only in https: vs. http: at the beginnning.

  2. Consider two bookmarks as duplicate if their URL matches up to the first ? symbol, i.e. only their additional information differs.

  3. Do not consider any bookmark from any folder named Mr. Dupe as a duplicate.

  4. Add all bookmarks to the list of duplicates, whether duplicate or not.

  5. Add all bookmarks from the folder Bookmark Menu | Remove to the list of duplicates (no matter whether they actually are duplicates).

  6. Consider two bookmarks as duplicate if they have the same name (instead of the same URL).

  7. Consider two bookmarks as duplicate if they reside in the same folder.

How to do the above tasks in Expert Mode

  1. Use the replacement rule: “Replace URL matches” ^http: “by” ^https:

Explanation: By replacing everywhere the URL beginnning with http: by https:, it does not matter whether the actual URL started with http: or https:. Of course, we could have exchanged the roles of http and https in our rule.

  1. Use the replacement rule: “Replace URL matches” \?.* “by” (empty string)

Explanation: Simply omit the ? symbol and all other symbols following it in all URLs.

  1. Use the filter rule: “Name matches” \0Mr\. Dupe\0 or \0Mr[.] Dupe\0

Explanation: If a bookmark is in a folder named “Mr. Dupe”, its full name (path) will contain the text “\0Mr. Dupe\0”; so match that text. Since the “.” symbol has a special meaning for regular expressions, we have to quote it. This can be done by either \. or by looking for a character class […] which contains only the single symbol ..

  1. Use the replacement rule: “Replace URL matches” .+ “by” http://dummy

Explanation: Pretend that every bookmark has the URL http://dummy by replacing all characters (.+) of the original URL by that text.

  1. Use the replacement rule: “Name Matches” ^Bookmark Menu\0Remove\0 “Replace URL matches” .+ “by” http://dummy

As in 4, but only for bookmarks whose full name starts with the matching path. This works only if the folder contains at least 2 bookmarks (because otherwise http://dummy is not a duplicate URL). Of course, one might use an actually duplicate URL instead of http://dummy to work around this limitation.

  1. Use the replacement rule: “Replace URL matches” .+ “by” $TITLE

Explanation: Replace all bookmark URLs by the corresponding bookmark title when looking for dupes.

  1. Use the replacement rule “Replace URL matches” .+ “by” $NAME followed by a further replacement rule “Replace URL matches” [^\0]*$ “by” (empty string)

Explanation: First replace the URL by its full name path, and then omit the last component of this path by cutting of the longest sequence of non-\0-symbols at the end.

Known Bugs

  1. Live bookmarks are falsely recognized as empty folders, see #4
  2. Stripping of descriptions works by replacing the bookmark by a freshly created one. In particular, it updates the bookmark creation date.
  3. Stripping of descriptions creates bookmarks in the place where it was when the displayed list was calculated, see #11 and the second part of #8
  4. In some firefox versions (e.g. 55.0.3) it has been reported that pressing the duplicate stars does not open a new tab. You can try to use the link in the options page of the extension instead if you have this problem. The reason for the problem is still unknown, see #38
  5. Android lacks the bookmark API necessary for bookmarkdupes: #53

Contributors

(in alphabetical order)

More Repositories

1

eix

eix can access Gentoo portage ebuild information and description very quickly (using a local cache). It can also be used to access information on installed packages, local settings, and local and external overlays, and informs about changes in the tree
C++
156
star
2

zram-init

A wrapper script for the zram linux kernel module with zsh and openrc support
Shell
76
star
3

squashmount

Init and management script for mounting rewritable squashfs-compressed data
Perl
42
star
4

push

A POSIX shell function to treat a variable like an array, quoting args.
Shell
33
star
5

mv-overlay

The mv overlay for gentoo
Shell
31
star
6

portage-bashrc-mv

Provide support for /etc/portage/bashrc.d and /etc/portage/package.cflags for the portage package manager (Gentoo Linux)
Shell
30
star
7

portage-env-mv

This is Martin Väth's local /etc/portage/env for gentoo, full of local fixes and hacks
15
star
8

zshrc-mv

This is a zsh initialization file (e.g. /etc/zshrc or ~/.zshrc) which activates a lot of zsh features
Shell
12
star
9

squash_dir

squash_dir is an init-script for OpenRC (used e.g. by Gentoo) which allows to keep a directory compressed by squashfs but simultaneously allows to write on it
Shell
11
star
10

termcolors-mv

256colors sample script and dircolors configuration for standard or 256 colors
Perl
9
star
11

portage-postsyncd-mv

postsync hooks for portage to sync from git
Shell
8
star
12

quoter

Quote arguments or standard input for usage in POSIX shell by eval
C
7
star
13

archwrap

A collection of POSIX shell scripts to invoke archiver programs
Shell
7
star
14

kernel

A POSIX shell script to compile the kernel with user permissions. Intended for Gentoo linux
Shell
7
star
15

replacer

Search and replace python regular expressions within many files interactively
Python
6
star
16

schedule

script to schedule jobs in a multiuser multitasking environment
Perl
6
star
17

logclean

Keep only compressed logs of installed packages (for Gentoo's portage system)
Perl
5
star
18

less-select

This is a patch to provide selection support for the "less" program
Perl
5
star
19

openrc-wrapper

openrc-wrapper - using some openrc scripts with systemd and other init systems
Shell
5
star
20

world

world is for the Gentoo portage system to organize your world file and to find installed packages or differences to @world (--depclean)
Shell
5
star
21

sshstart

Start ssh-agent/ssh-add only if you really use ssh or friends
Shell
5
star
22

firewall-mv

Initialize iptables and net-related sysctl variables
Shell
5
star
23

grub-cfg-mv

grub-cfg-mv - A grub.cfg library/example for GRUB2
4
star
24

video-mv

Frontends for using mplayer/mencoder, ffmpeg/libav, or tzap as video recorder
Shell
4
star
25

set_prompt

An intelligent prompt for zsh or bash with status line (window title) support
Shell
4
star
26

emount

mount/unmount (and create/remove) dm-crypt filesystems according to your /etc/fstab
Perl
3
star
27

runtitle

Scripts to run commands and set the hard status line (windows title)
Shell
3
star
28

m5figur-mv

LaTeX2e character sheet layout for the Midgard Role Playing Game (Edition M5)
TeX
3
star
29

pyrep

Search and/or replace regular expressions within many files interactively
Python
3
star
30

sudox

sudox is a wrapper for sudo which can pass X authority data and deal with screen and tmux
Shell
3
star
31

comp

compare files or directories, including metadata
Perl
2
star
32

calc-extension

A WebExtension: Calculate values of mathematical expressions
JavaScript
2
star
33

trickyfetch

This project is for the Gentoo portage system to cleanup or organize DISTDIR
Shell
2
star
34

find_cruft

Find cruft files on Gentoo and similar distributions
Perl
2
star
35

machine-learning-mv

Some Machine Learning Experiments
Perl
2
star
36

diffhelp

A POSIX script acting as a frontend, beautifier, and path-fixer for diff -u
Shell
2
star
37

chessproblem

Chess and chess problem C++11 libraries with a demo program for finding solutions of chess problems (mate, selfmate, and helpmate) with cooks
C++
2
star
38

cpi

A POSIX shell wrapper for "cp -i -a", making use of "diff".
Shell
2
star
39

knapsack

knapsack - A fast solver for the 0/1-knapsack problem with multiple knapsacks
C++
2
star
40

starter

POSIX shell script and function to schedule commands
Shell
2
star
41

bzwc

A POSIX shell wrapper for "wc" supporting compressed files (.xz .lzma .bz2 .gz)
Shell
1
star
42

dsa-stats

dsa-stats - calculate probabilites for DSA ("Das schwarze Auge")
Perl
1
star
43

changelog-gitrepo

Create ChangeLog data for gentoo repositories from git
Shell
1
star
44

git-wrappers-mv

git-wrappers-mv - Some personal wrappers for the most important git commands
Shell
1
star
45

paxopen

A wrapper script to set PAX kernel variables to an insecure/safe state
Shell
1
star
46

osformat

A C++ library for a typesafe printf/sprintf based on << conversion
C++
1
star
47

mv_emacs

mv_emacs - Packages for (X)Emacs: block support, macrorecorder, verify changes
Emacs Lisp
1
star
48

useflags

Print or save the current USE-flag state of the Gentoo portage system and compare with older versions
Perl
1
star
49

mv_perl

mv_perl - A collection of perl scripts (replacement in files, syncing dirs etc)
Perl
1
star