问题
Using tampermonkey and greasymonkey. When I use userscript with // @grant none
it gets current page variables window[variable].id
. But when used any Gm_ function (GM.info not affect) it wont work. Because now userscript running in sandbox. How can I get current page <script type="text/javascript"></script>
variables or I should use regexp?
Example:
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*/*
// @grant GM_xmlhttpRequest
// @noframes
// ==/UserScript==
var prop =Object.keys(window).find(key => key.startsWith('variable'));
alert(prop)
prop=window[prop]
GM_xmlhttpRequest({
method: "HEAD",
url: prop,
onload: function(x) {
alert(x)
}})
来源:https://stackoverflow.com/questions/63160273/cant-find-page-variables-when-used-gm-functions