如何在浏览器之外编辑Tampermonkey脚本

eCo*_*Evo 19 javascript google-chrome tampermonkey

如何在浏览器之外编辑Tampermonkey脚本?宁愿在一个好的IDE中,而不是试图在浏览器中进行编辑.

当我在Firefox中开发Greasemonkey脚本时,我曾经能够这样做,但我无法使用Chrome找到.user.js文件.

der*_*anb 20

由于Chrome扩展程序并未真正(下面的说明)可以访问文件系统,因此Tampermonkey会将脚本存储在内部存储中.

您可以做的是允许Tampermonkey访问您的本地文件,将脚本的标题复制到Tampermonkey,另外@require位于硬盘某处的完整脚本.

" do not really "意味着LocalFileSystem API允许文件访问,但名称和文件不一定映射到真实文件系统.此外,LocalFileSystem现在似乎已被弃用.

  • 个人资料图片检查 (2认同)

小智 15

转到Extensions> Tampermonkey>允许访问文件URL

然后,将脚本设置为:

// ==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==
Run Code Online (Sandbox Code Playgroud)

我知道这个帖子的作者有点晚了,但这就是我开发的方式......

然后,使用确切的标头设置脚本,因此我包含的示例文件:video_site_ultimate_tool.js是

// ==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...' );
Run Code Online (Sandbox Code Playgroud)

我将它们设置为相同(好吧,我将文件系统脚本中的@requires更改为http变体,因此functions_lib会转到bitbucket,而video_site_ultimate_tool将被删除,并且脚本在复制到我的bitbucket repo时放入...

它真的加快了开发速度,能够使用外部编辑器并立即显示更改...

希望这有助于下一个人..

注意:我建议使用Opera - 它比chrome快得多,因为它没有内存泄漏并附带内置广告拦截器.我遇到的唯一问题是,你只能通过调整Opera的大小来重新组织扩展栏,然后使用下拉菜单移动扩展(但前4个将始终是在他们的位置 - 甚至编辑json不会因某种原因改变顺序 - 查看它因为json文件的编辑方式与手动完成时相同)所以我建议你先安装4个工具栏扩展不要使用和禁用它们 - 然后当你想重新排序,启用,调整大小,订购,禁用时.

或者,如果你先安装,我建议先确定你想要的东西 - 在大多数情况下我使用OneTab,UMatrix,UBlock Origin,TamperMonkey和Stylish作为前5个..