无法使时尚脚本站点特定

发布于 2024-10-19 21:52:34 字数 666 浏览 5 评论 0原文

我在 Firefox 上有一个时尚脚本,可以移动起始页上的搜索按钮,但问题是它也会移动其他页面上的搜索按钮。

@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")

OR

@-moz-document domain("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")

不起作用。 “搜索”按钮将在任何有该按钮的页面上移动。

有什么想法可以使其针对特定站点吗?

这是脚本:

@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query="){

}
  input[value="Search"] /*isolates button*/
  {
   position: absolute;
   top: 311px;
   left: 660px;
  }

Firefox 3.6.14,Win 2K

I have a Stylish script on Firefox that moves the Search button on Starting Page, but the problem is that it will move the Search button on other pages, as well.

The lines

@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")

OR

@-moz-document domain("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")

do not work. The Search button will move on any page that has it.

Any ideas to make it site-specific?

Here’s the script:

@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query="){

}
  input[value="Search"] /*isolates button*/
  {
   position: absolute;
   top: 311px;
   left: 660px;
  }

Firefox 3.6.14, Win 2K

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

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

发布评论

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

评论(2

平安喜乐 2024-10-26 21:52:34

一般答案:

第一行 (@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")) 应该工作。它只是因为其他页面也受到影响而失败,还是因为它从不触发而失败?

无论如何,要检查的事情:

  1. 是否省略了左大括号?通常这些行是这样的:

    @-moz-document url("http://www.google.com/hl=en&q=foo&aq=f") {
    

    注意末尾的大括号(但是编辑下一行的大括号也可以。

  2. 起始页之后的下一页是否由 AJAX 加载?例如,Google 会这样做。不重新加载。
    如果是这种情况,那么 Stylish 仍将覆盖有效的样式;时尚中没有任何帮助。

因此,请确认第一行的问题。最好包含目标页面和完整脚本的确切链接。

如果是 AJAX 问题,那么您可以轻松地将 Stylish 脚本转换为 Greasemonkey 脚本——只需一点逻辑,它就可以正确应用样式,即使在 Ajax 化的页面上也是如此。 (如果是这种情况:标记此问题已回答并打开一个新问题,提供完整的时尚脚本和所需的结果。)


具体答案,基于来自OP的新信息:

根据提供的脚本,错误是大括号位置错误。另外,您应该提供一个名称空间。

因此,将脚本文本替换为:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")
{
    input[value="Search"] /*isolates button*/
    {
        position: absolute;
        top: 311px;
        left: 660px;
    }
}

General answer:

That first line (@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")) should work. Does it only fail because other pages are also affected or does it fail because it never fires?

Anyway, things to check:

  1. Was the opening brace omitted? Usually those lines are like:

    @-moz-document url("http://www.google.com/hl=en&q=foo&aq=f") {
    

    Note the brace at the end (But editing for the brace on the next line is fine, too.

  2. Are the next pages, after the Starting Page, being loaded in by AJAX? For example, Google does this. You will notice that after entering a search term, the entire page does NOT reload.
    If this is the case, then Stylish will still have the overwritten styles in effect; there is no help for it in Stylish.

So, confirm the problem with your first line. It would also be good to include exact links to the target pages and the full script.

If it is an AJAX issue, then you can easily convert the Stylish script to a Greasemonkey script -- which can, with a little logic, apply styles correctly, even on Ajaxified pages. (If that is the case: mark this question answered and open a new question, providing the full Stylish script and the desired results.)


Specific Answer, based on new information from the OP:

Based on the script provided, the error is that the braces are mispositioned. Also, you should provide a namespace.

So replace the script text with:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")
{
    input[value="Search"] /*isolates button*/
    {
        position: absolute;
        top: 311px;
        left: 660px;
    }
}
后来的我们 2024-10-26 21:52:34
@-moz-document url-prefix("http://startingpage.com/eng")

或者

@-moz-document domain(startingpage.com)
@-moz-document url-prefix("http://startingpage.com/eng")

or

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