How to edit Tampermonkey scripts outside of the browser

本小妞迷上赌 提交于 2019-11-28 21:17:54

问题


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.


回答1:


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.




回答2:


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..



来源:https://stackoverflow.com/questions/24542151/how-to-edit-tampermonkey-scripts-outside-of-the-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!