在全局范围内查找JavaScript函数 [英] Finding JavaScript function in the global scope
问题描述
有没有办法在当前活动对象模型中搜索JavaScript属性(例如命名函数)(DOM选项卡上显示的是Firebug,在Chrome Developer Tools中找不到直接的等价物)使用主要浏览器的常用开发工具?
Is there a way to search for a JavaScript attribute (e.g. a named function) in the currently live object model (what Firebug displays on the 'DOM' tab, I couldn't find a direct equivalent in the Chrome Developer Tools) of the currently loaded page, using the common developer tools of the main browsers?
一个例子是我搜索beta,开发人员工具显示我的东西 window.alpha.beta
,这意味着某些脚本文件已经在窗口对象上创建了一个名为alpha的对象,该对象具有属性beta。
An example would be that I search for 'beta' and the developer tools show me something like window.alpha.beta
, meaning that some script file has created an object named 'alpha' on the window object, which has an attribute beta.
我明确地不想在所有脚本文件中搜索字符串(例如 Ctrl-Shift-F
Chrome开发人员工具)。
I explicitly do not want to search for strings in all script files (e.g. Ctrl-Shift-F
in the Chrome Developer Tools).
用例是我想从扩展名/ userscript调用该页面的功能。我知道这个函数是存在的,但是它是使用一个复杂的框架创建的,我不知道页面的对象模型中哪里最终出现。
The use case is that I want to call a function of the page from an extension/userscript. I know the function exists, but it is created using a complex framework and I can't tell where in the page's object model it ends up.
PS:术语相关
推荐答案
加载 https://github.com/angus-c/waldo ,并从控制台使用它看起来应该做的伎俩。一点点复杂,但也与工具无关。
Loading https://github.com/angus-c/waldo and using it from the console looks like it should do the trick. A little more complex but also tool-agnostic.
这篇关于在全局范围内查找JavaScript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!