运行 个参数来自 Chrome 控制台的自定义函数

Running custom functions with arguments from Chrome console

我想使用 Chrome 控制台连接到 运行 一些 JavaScript 行。感谢 tampermonkey,我得到了这个工作,我有这样的东西 运行s 用于任何网络:

window.req= function(){

    token = getToken()...
    link = "http://hello.com/"  + parameter + "/token=" + token;
    window.open(link);
    };

这非常有效,我能够从页面和控制台上 运行 req() 获得我需要的信息。

我面临的问题是我完全无法发送参数。我通过像这样设置它们来做到这一点:

parameter = "thing"
req()

但是太丑了,我想这样做:

req("thing")

但是我无法使带有参数的自定义函数在 Chrome 的控制台上工作。

这对我有用:

window.getToken = function() { return "token12626"; }

window.req= function(parameter){
    token = getToken()
    link = "http://hello.com/"  + parameter + "/token=" + token;
    window.open(link);
    };

req("thing")