我目前正在尝试弄清楚如何在我的网络服务器上的 scriptish/greasemonkey 脚本中包含一个 javascript,并让它在每次调用用户脚本时重新加载脚本。
我正在我的网络服务器上编辑脚本,我真的不想每次对包含的脚本进行更改时都重新安装用户脚本。
有什么办法可以解决这个问题吗?我一直在寻找答案,但到目前为止没有找到答案。
明确地说,我的用户脚本如下所示:
// ==UserScript==
// @id HET
// @name SettingsHandler
// @version 1.0
// @namespace HET
// @require http://urltoscript/scripts/he/lib.js
// @run-at document-end
// ==/UserScript==
我的外部脚本如下所示:
alert('got it');
所有这些对于测试目的来说仍然非常容易。此设置有效,但只有第一次,当我更改我的 lib.js 脚本时,用户脚本仍会读取旧脚本。有没有办法阻止用户脚本缓存外部脚本?或者是否有任何其他元标记可以帮助我?
提前致谢, 戴夫
最佳答案
这是唯一可行的答案 https://github.com/Tampermonkey/tampermonkey/issues/475
推荐选项 4。但是它们是异步加载的,因此加载顺序可能不同
There are several ways to ease your pain. :)
- You can increase the version number before saving the script and all external resources will be reloaded.
- After setting "Config mode" to "Advanced" you can configure the external update interval. Note: "Always" still means after the resource was used. So you might need to execute/load the page twice.
- If you use Tampermonkey Beta (Chrome or Firefox) you can edit the external resource in place (because there now is a edit button besides the delete button).
- Copy the resources and store them locally. After you've enabled "Local file access" at Chrome's extension management page or Tampermonkey's settings page (if you're using Firefox) you can @require them via a local file:// URI.
关于javascript - 如何防止@require 缓存外部js 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30109626/