Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit Tampermonkey scripts outside of the browser

How do I edit Tampermonkey scripts outside of the browser? Would rather be in a good IDE instead of trying to make the edits in the browser.

I used to be able to do this when I developed Greasemonkey scripts in Firefox, but I can't locate the .user.js files with Chrome.

like image 763
eComEvo Avatar asked Jul 02 '14 22:07

eComEvo


2 Answers

Go to Extensions > Tampermonkey > Allow access to file urls

Then, set your script as:

// ==UserScript== // @name            Acecool - Video Site - Ultimate Video Site Management, Ad Removal, Redirection, Direct-Linking and more! // @author          Acecool // @namespace       Acecool // @version         0.0.1 // @description     Replaces encoded-links with decoded direct-links on episode finder sites. // @description     Automatically click the "continue" button, and attempt to skip the countdown if any, on video watching sites. // @description     Remove ad panels on video watching sites. // @match           http://*/* // @require         http://code.jquery.com/jquery-latest.js // @require         file:///C:/AcecoolGit/acecooldev_userscripts/libraries/acecool_functions_lib.js // @require         file:///C:/AcecoolGit/acecooldev_userscripts/video_sites/video_site_ultimate_tool.js // @grant           GM_xmlhttpRequest // ==/UserScript== 

I know it is a bit late for this thread author, but this is how I develop...

Then, the scripts are set up with the exact header as that so the example file I include: video_site_ultimate_tool.js is

// ==UserScript== // @name            Acecool - Video Site - Ultimate Video Site Management, Ad Removal, Redirection, Direct-Linking and more! // @author          Acecool // @namespace       Acecool // @version         0.0.1 // @description     Replaces encoded-links with decoded direct-links on episode finder sites. // @description     Automatically click the "continue" button, and attempt to skip the countdown if any, on video watching sites. // @description     Remove ad panels on video watching sites. // @match           http://*/* // @require         http://code.jquery.com/jquery-latest.js // @require         file:///C:/AcecoolGit/acecooldev_userscripts/libraries/acecool_functions_lib.js // @require         file:///C:/AcecoolGit/acecooldev_userscripts/video_sites/video_site_ultimate_tool.js // @grant           GM_xmlhttpRequest // ==/UserScript== alert( 'test script is running from the file system instead of from TM...' ); 

I set them up identically ( well, I change the @requires in the file-system script to be the http variants, so the functions_lib goes to bitbucket while video_site_ultimate_tool would be deleted and the script put in when copied to my bitbucket repo...

It really speeds up development to be able to use an external editor and have the changes appear immediately...

Hopefully this helps the next person..

like image 195
Acecool Avatar answered Sep 28 '22 02:09

Acecool


Since Chrome extensions don't really (explanation below) have access to the filesystem Tampermonkey stores the scripts at an internal storage.

What you can do is to allow Tampermonkey to access your local files, copy the header of your script to Tampermonkey and additionally @require the full script that is located somewhere at your hard disk.

"don't really" means the LocalFileSystem API allows file access but the names and also the files are not necessarily mapped to the real filesystem. Furthermore LocalFileSystem seems to be deprecated now.

like image 22
derjanb Avatar answered Sep 28 '22 03:09

derjanb