无法使时尚脚本站点特定
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般答案:
第一行 (
@-moz-document url("http://startingpage.com/eng/advanced-search.html?&cat=web&query=")
) 应该工作。它只是因为其他页面也受到影响而失败,还是因为它从不触发而失败?无论如何,要检查的事情:
是否省略了左大括号?通常这些行是这样的:
注意末尾的大括号(但是编辑下一行的大括号也可以。
起始页之后的下一页是否由 AJAX 加载?例如,Google 会这样做。不重新加载。
如果是这种情况,那么 Stylish 仍将覆盖有效的样式;时尚中没有任何帮助。
因此,请确认第一行的问题。最好包含目标页面和完整脚本的确切链接。
如果是 AJAX 问题,那么您可以轻松地将 Stylish 脚本转换为 Greasemonkey 脚本——只需一点逻辑,它就可以正确应用样式,即使在 Ajax 化的页面上也是如此。 (如果是这种情况:标记此问题已回答并打开一个新问题,提供完整的时尚脚本和所需的结果。)
具体答案,基于来自OP的新信息:
根据提供的脚本,错误是大括号位置错误。另外,您应该提供一个名称空间。
因此,将脚本文本替换为:
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:
Was the opening brace omitted? Usually those lines are like:
Note the brace at the end (But editing for the brace on the next line is fine, too.
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:
或者
or