gpt4 book ai didi

javascript - 如何在页面开始加载之前将参数附加到 URL?

转载 作者:行者123 更新时间:2023-12-02 19:21:48 25 4
gpt4 key购买 nike

在 Chrome 中,我希望检测页面 URL 是否位于 example.com 的域中,如果是,则在加载之前附加 foo=bar 作为参数并加载它。

我发现当多功能栏为 submitted here 时我可以访问,但看起来它无论如何都会加载原始 URL,虽然这好吧,但它是我认为必要的带宽的两倍。当只有一个页面时这不是问题,但这是需要在站点中的每个页面上进行的更改,因此双倍带宽肯定会成为问题。

目前,它会检测 URL 是否为 example.com 并已提交,然后调用 window.stop() 并设置 location.hrefexample.com/&?foo=bar 但这似乎并不理想。

简而言之,用户访问 http://www.example.com,然后脚本将其更改为 http://www.example.com/&?foo=加载原始链接之前的栏

最佳答案

看看chrome.webRequest API,特别是以下方法:

onBeforeRequest (optionally synchronous)

Fires when a request is about to occur. This event is sent before any TCP connection is made and can be used to cancel or redirect requests.

关于javascript - 如何在页面开始加载之前将参数附加到 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12463424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com