域 .* 的调度在 IE 中不起作用

发布于 2024-10-31 00:59:07 字数 164 浏览 3 评论 0原文

我们有一个扩展需要在用户加载的每个页面上触发。我们尝试在调度块中使用域“.*”来完成此操作。虽然这在 Firefox 和 Chrome 中效果很好,但 IE 根本不尊重这一点。

这是一个已知问题还是对域“.*”有任何解决方法?不幸的是,我们处于一个独特的情况,我们无法列出我们想要启动扩展的所有域。

We have an extension that needs to fire on every page the user loads. We have tried to accomplish this using domain ".*" in the dispatch block. While this works great in firefox and chrome, IE doesn't respect this at all.

Is this a known issue or are there any work arounds to the domain ".*"? Unfortunately we are in a unique situation where we can't list all the domains we want to fire our extension on.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三月梨花 2024-11-07 00:59:08

看来我找到了自己问题的答案。

Kynetx IE 版本似乎不支持开箱即用。目前使用的是c#函数:

if (document.domain.EndsWith(domain))
{
    plantTags = true;
    break;
}

plantTags是一个标志,用于显示是否将扩展代码放在页面上。 EndsWith 只是查看当前字符串 (document.domain) 是否以您传递的内容结尾。知道这一点,您可以放入域“.com”域“.net”等,它应该在所有页面上工作,尽管我没有测试这一点。

相反,我只是使用正则表达式,将其添加到文件 BHO/BHO.cs 的第 6 行:

using System.Text.RegularExpressions;

然后将第 182-190 行从: 更改

foreach (String domain in domainlist)
{
    //reportMessage("onDocComplete", "Matching " + domain + " to doc domain " + document.domain);
    if (document.domain.EndsWith(domain))
    {
        plantTags = true;
        break;
    }
}

为:

foreach (String domain in domainlist)
{
    Regex objDomainPattern = new Regex(domain);
    //reportMessage("onDocComplete", "Matching " + domain + " to doc domain " + document.domain);
    if (objDomainPattern.IsMatch(document.domain))
    {
        plantTags = true;
        break;
    }
}

从那里我只需重新编译扩展代码(说明包含在下载有关如何执行此操作的源代码),然后我就走了!我的 IE 扩展现在将根据域块中的正则表达式进行匹配。希望有一天这可以帮助别人!

Looks like I found the answer to my own question.

It doesn't look like the Kynetx IE version supports this out of the box. It's currently using the c# function:

if (document.domain.EndsWith(domain))
{
    plantTags = true;
    break;
}

plantTags is a flag used to show put the extension code on the page or not. EndsWith just sees if the current string (document.domain) ends with whatever you pass it. Knowing this, you could put in domain ".com" domain ".net" etc and it should work on all pages, though I didn't test this.

Instead, I just used regex by adding this at line 6 in the file BHO/BHO.cs:

using System.Text.RegularExpressions;

And then changing lines 182-190 from:

foreach (String domain in domainlist)
{
    //reportMessage("onDocComplete", "Matching " + domain + " to doc domain " + document.domain);
    if (document.domain.EndsWith(domain))
    {
        plantTags = true;
        break;
    }
}

To:

foreach (String domain in domainlist)
{
    Regex objDomainPattern = new Regex(domain);
    //reportMessage("onDocComplete", "Matching " + domain + " to doc domain " + document.domain);
    if (objDomainPattern.IsMatch(document.domain))
    {
        plantTags = true;
        break;
    }
}

From there I just had to re-compile the extension code (instructions are included with the source download on how to do this) and I was off! My IE extension now will do a match based on a regex from the domain block. Hope this helps someone else out someday!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文