Creating screenshots with own names (timestamps, domains, pathnames etc)

I hope I’ll be able to answer few requests you can found there:

FEATURE TITLE ► Screenshots names with timestamps
FILE TITLE ► screenshots@mozilla.org.xpi
OBJECT TITLE ► shot.js
XPI SOURCEShttps://yadi.sk/d/cIjp3ivQenKWPA?w=1

The answer describes procedure allowing change screnshot names in GNU/Linux (Debian Bullseye), but XPI files should be working in Win as well (not checked).

I assume you are acquainted well with the owners issues in GNU systems. I use Midnight Commander for every system doings (editing etc). Red background in MC windows informs me of root ownership (green was chosen for me, the main user).

  1. Go to the directory where you installed Firefox. I did it manually to the /opt directory.

  2. Create additional directory firefox.testbed there and new screenshots@mozila.org directory inside it.

  3. Go to /opt/firefox/browser/features/ directory where you’ll find xpi files. They are zipped files. Find screenshots@mozila.org.xpi and copy it to the /opt/firefox.testbed/screenshots@mozila.org. MC works as all the world File Commanders, so you won’t have any issues with using MC. You can turn to CLI environment too:
    cp screenshots@mozilla.org.xpi /opt/firefox.testbed/screenshots@mozilla.org

  4. Move to the target directory and then unzip the xpi archive:
    unzip screenshots@mozilla.org.xpi

ssfx_0014

  1. Go to the build directory, there is placed shot.js file - the culprit of all those evils of Firefox screenshot name issues. :wink:

  2. Open the file in an editor, I used MC’s mcedit (F4 in MC). It contains the following function code named get filenam() { :

Here I must stop. I beg your pardon, but you have to read the javascript code yourself. No place here to play with it, but the function code can be changed with a small intellectual efforts (for those who dares :wink: ). I did my homework, so I am able to share with forum readers my four xpi files which change Firefox screenshot names.

  1. When you “make the changes” you must to zip the directory screenshots@mozilla.org from within: (the best use 7zip)
    7z a ../screenshots@mozilla.org.xpi * -r

  2. Move up from the directory to where you have created corrected xpi file.
    Apply (rename) to your new file a meaning name, e.g. screenshots@mozilla.org.timestamp.xpi. I did that because I have made few xpi versions. Thanks to them:

  • all screenshots gained timestamp
  • all screenshot names gained domain names instead of traditional page titles - there are short names and very long ones, too long to my liking too, although one user requested opposite - unlimited page titles.
  • I make frequently screenshots of directory pages which have addresses starting with file prefix:
    file:///home/user/xxx/yyy/zzz/
    In such cases new screenshot names contain pathnames instead of domain names. That’s why I have conjured up few versions to which I applied meaningful names, namely:
  • screenshots@mozilla.org.domain.pathname.xpi (screenshot names with timestamps, domain names or pathnames)
  • screenshots@mozilla.org.filename.128.xpi (page name limited to 127 characters)
  • screenshots@mozilla.org.filename.255.xpi (original Firefox xpi file with 255 characters limit)
  • screenshots@mozilla.org.filename.limitless.xpi (for screenshot names with page titles of unlimited length)

ssfx_0012

Why have I changed original screenshots@mozilla.org.xpi file to screenshots@mozilla.org.filename.255.xpi? To have flexibility in selection of screenshot names.

Anyway, there are some caveats. The first sad thing is that Firefox accepts original screenshots@mozilla.org.xpi name only (to my scarce knowledge). The good is that you can change the contents. The second bad issue - after selection of new xpi file you’d have to reload Firefox.

  1. Back to the next steps. When you create all your new XPI files with different names copy them to Firefox original directory:

mv screenshots@mozilla.org.*.xpi /opt/firefox/browser/features

Do remember to remove (delete or move to other directory) original file screenshots@mozilla.org.xpi. Otherwise you will not be able to create symlink to original xpi name.

  1. Being in the /opt/firefox/browser/features directory, create symlink to your favorable xpi file, e.g.:
    ln -s screenshots@mozilla.org.domain.pathname.xpi screenshots@mozilla.org.xpi

Screenshot I created and which illustrate the above text are placed in Yandex disk. All four versions of xpi files are there too. Use XPI SOURCES address presented at the beginning of this mini article.

There you’ll find a special image ssfx_0007.png (below). It needs explanation.

Numbers - 1,2,3,4 are names of screenshots I tested for the page shown on ssfx_0000.png (below).

'*' [star] = screenshots@mozilla.org.

No.1 is original screenshot name from unchanged Firefox. Consecutive names were tested. In the end I’ve chosen 4th version (**.domain.pathname.xpi* file)

Numbers 5-8 concerns domain worldometers.info.
No.8 comes from *.domain.pathname.xpi.
No.7 was created by *.filename.127.xpi.
No.6 is result of *.filename.limitless.xpi.
No.5 name “produced” original file *.filename.255.xpi.

That’s all. Thank you.