使用 Firefox SDK 自动进行 Wi-Fi 授权

Automating Wi-Fi Authorization with Firefox SDK

我正在尝试使用 Firefox Add-on SDK 和 API 制作一个 Firefox 插件,在开始使用它们之前我对它们的可能性有一些疑问。

我大学的 Wi-Fi 授权每 30 分钟过期一次,只是为了找点乐子惹恼他们的学生。许多浏览器上已经有一些自动填充插件可用,但是将鼠标指针移动到 "Login" 按钮上并在还剩一秒钟提交期中论文时单击它仍然是破坏性的。几个月来我一直听到我的朋友这样抱怨,我自己也觉得这件事有时真的很烦人,所以我决定开发一个 Firefox 插件来负责这项工作,这样一旦插件完成,授权过程就感觉不存在了活性。 (我只是想诚实地打动我的朋友。)

为方便起见,我想在 Firefox 附加组件 SDK 中开发附加组件。我发现我的插件会使用 page-modpasswordrequest API; page-mod 检测 Wi-Fi 服务自动重定向到他们的授权页面,password 通过存储在个人 Firefox 浏览器中的学生 ID 和密码填写页面的表单,request 到将 "Login Successful!" 页面重定向到最初给定的目的地。

所以我想用这个SDK和APIs应该可以实现我的目标,但是在继续之前我还需要问一些问题:

非常感谢您的阅读,请抽出一点时间来陪我。再次感谢!

Is it possible to pass a callback function to page-mod::PageMod (not as a String or a URL to another JavaScript file)? If not, can it be done using the lower level API?

不,通过端口的所有内容都使用 JSON 序列化 (See docs) 进行序列化。相反,您可能会从内容脚本发出一个事件,以使用您在模块范围内传递给它的参数执行回调方法,并对需要在内容脚本中使用端口事件侦听器完成的部分进行硬编码。

Is it possible to actually redirect a page in a tab into another page only using high level APIs?

总的来说,如果您在内容脚本中,您可以只设置 window.location,或者在您的模块中设置选项卡的位置,请参阅 https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/tabs#url

Is it possible to remember the original destination's location (with the request method and contents) and call it in the process of page-mod::PageMod (in order to re-redirect out of the authorization page)? If not, can it be done using the lower level API?

可能吗?是的,很大程度上取决于 W-LAN 的重定向如何工作。通常,所有 SDK 都为您提供获取选项卡的 load/ready 事件并读取选项卡的当前 URL。因此,如果您在重定向时获得就绪事件,就可以了。如果你的大学登录名记得使用 URL 中的 get 参数的重定向目标,你就没问题。如果你的大学不调整 URL,你就没事。如果您真的需要深入挖掘请求,您将不得不比 SDK 为您提供的更深入,但这是可能的。

Is it possible to perform the addon's redirection function on inactive (background) tabs where the opened webpages automatically keep connecting to the Internet and get redirected to the authorization page?

加载项的 JS 执行不会根据选项卡状态暂停。