Search in Userscripts code

Post Reply
takezo
Posts: 3
Joined: 25.11.17 15:46:16

Search in Userscripts code

Post by takezo » 25.11.17 15:53:36

I have currently 228 scipts, most of them written by myself.

Often I encounter a problem I know I already solved in another script.
Not so long ago, when I was using GreaseMonkey in Firefox 56, I just did a text search in my external code editor with a specific keyword and found the wanted snippet in any script of the folder "gm_scripts".

But now, with TamperMonkey and the embedded scripts, I cannot do that, the search in "Installed userscript" does not even look at the script code it seesms.

Could you add a more powerful search function for example in this "Installed userscripts" tab, to search in the code itself ?

Thanks.

takezo
Posts: 3
Joined: 25.11.17 15:46:16

Re: Search in Userscripts code

Post by takezo » 26.11.17 12:07:17

As a workaround, I made a bash script to achieve this by looking at storage.js:

Code: Select all

#!/bin/bash

python -mjson.tool ~/.mozilla/firefox/[PROFILE_NAME]/browser-extension-data/firefox@tampermonkey.net/storage.js | grep -A2 -E "@(uid|source)#" | grep -v ': "",' | grep -v '"origin": "normal",' | grep -Ev '^--$' | perl -p -e 's/": \{\n//g' | sed -r 's/    "@source#/    "@uid#/' | sort | grep --color -B1 "$@"
For example, if you named the script "userscriptsgrep" and you search for "pad(", you type:

Code: Select all

userscriptsgrep "pad("
This will write two lines for each script containing "pad(":
  • one with the script's name
  • one with the code, everything on one line though, so not easily readable
Not ideal but at least I know which script to open in TM to find a snippet.

A way to do that directly in TM interface would be so much better !

Or should I open an issue on GitHub ?

User avatar
derjanb
Site Admin
Posts: 2383
Joined: 20.01.06 02:16:15
Contact:

Re: Search in Userscripts code

Post by derjanb » 09.12.17 15:50:35

takezo wrote:
25.11.17 15:53:36
Could you add a more powerful search function for example in this "Installed userscripts" tab, to search in the code itself?
The scripts source is loaded only on purpose, but I'll think about a way to achieve this.
ImageIf you like what I'm doing, please consider a donation here. Image

User avatar
derjanb
Site Admin
Posts: 2383
Joined: 20.01.06 02:16:15
Contact:

Re: Search in Userscripts code

Post by derjanb » 28.01.18 22:40:02

TM Beta 4.6.5694 allows the source code to searched as well.
ImageIf you like what I'm doing, please consider a donation here. Image

takezo
Posts: 3
Joined: 25.11.17 15:46:16

Re: Search in Userscripts code

Post by takezo » 21.02.18 22:16:39

I just updated my Firefox add-ons and was very excited to see the line "Allow script source code to be searched as well" in the changelog for Tampermonkey !
It works wonderfully, thank you very much ! :D

Post Reply