【问题标题】:How to edit Tampermonkey scripts outside of the browser如何在浏览器之外编辑 Tampermonkey 脚本
【发布时间】:2014-08-23 21:29:38
【问题描述】:

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

我以前在 Firefox 中开发 Greasemonkey 脚本时能够做到这一点,但我无法在 Chrome 中找到 .user.js 文件。

【问题讨论】:

  • 为什么不在任何随机编辑器中编辑它们并复制/粘贴?
  • @Pointy 因为我在开发相当长的脚本时做了很多更改。复制/粘贴将在编码和页面加载之间添加另一组步骤,以确保新功能正常工作。

标签: javascript google-chrome tampermonkey


【解决方案1】:

由于 Chrome 扩展程序并没有真正(下面的解释)访问文件系统,Tampermonkey 将脚本存储在内部存储中。

你可以做的是allow Tampermonkey to access your local files,将你的脚本头复制到Tampermonkey,另外还有@require the full script that is located somewhere at your hard disk

不真正”表示 LocalFileSystem API 允许文件访问,但名称和文件不一定映射到真实的文件系统。 Furthermore LocalFileSystem seems to be deprecated now.

【讨论】:

  • 头像签出
  • @kres0345 ofc,是 Tampermonkey 的作者 :)
  • 火狐呢?
【解决方案2】:

转到扩展 > 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==

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

然后,脚本被设置为正确的标题,所以我包含的示例文件: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...' );

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

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

希望这可以帮助下一个人..

【讨论】:

    猜你喜欢
    • 2015-06-22
    • 2012-11-09
    • 1970-01-01
    • 2011-11-12
    • 2012-02-23
    • 2018-12-01
    • 1970-01-01
    • 2018-10-03
    • 2013-01-11
    相关资源
    最近更新 更多