Can't find page variables when used GM_ functions

為{幸葍}努か 提交于 2021-01-29 15:21:02

问题


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

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