从命令行运行 Firefox 插件

发布于 2024-08-07 22:25:30 字数 264 浏览 6 评论 0 原文

我正在为网站制定 508 可访问标准。有一个 Firefox 插件可以帮助检查网站的每个页面 WAVE 插件
我有一个爬虫可以遍历网站的所有页面。
现在我想结合 WAVE 插件 + 我的爬虫来自动检查网站是否符合 508 可访问性合规性。

我的问题是如何从命令行运行具有特定 URL 的 Firefox 插件?

感谢您的帮助,

I am working 508 accessible standard for a website. There are a Firefox plugin to help check on each page a website WAVE addons
I am having a crawler that walk throught all pages of the website.
Now i want to combine WAVE addons + my crawler to check website as 508 accessibility compliance automatically.

My question is how to run Firefox addons with a specific URL from command line?

Thanks for your help,
Minh

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

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

发布评论

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

评论(2

尽揽少女心 2024-08-14 22:25:30

编辑 2023 年,解决方法阻止顶级数据: 进一步查看!

从命令行运行 Firefox Extras。

您可以从命令行执行许多复杂的操作,如运行内联 JavaScript(我发布了彩色 RGB 淋浴另一个 方法,在答案的底部)。

也许这可以帮助你:

$ firefox 'data:text/html;charset=ISO-8859-1,
<html>
<head>
<title>TEST Demo</title>
</head>
<body>
<h3 id="title">Test demo</h3>
<script language="javascript">
window.open("http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg","clock","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=400,top=36,left=700");                                     
window.open("https://stackexchange.com/users/flair/1965184.png","netrate","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=208,height=58,top=36,left=490");
var s=10;                                                                 
function cntdwn()                                          
{                                                                 
  document.getElementById("title").innerHTML="Test demo: "+s;s=s-1;
  if (0 > s)                                                      
  {                                                                      
    window.location="https://stackoverflow.com/a/13013464/1765658";
  }                                                                      
  else window.setTimeout(cntdwn,1000);
  };                                        
  window.onload=cntdwn;
 </script>
 </body>'

这可以写成:

$ firefox 'data:text/html;charset=ISO-8859-1,<html><body><h3 id="title"></h3>'"$(
    cat <<eof
        <script language="javascript">
        var s=10;
        function cntdwn() {
            document.getElementById("title").innerHTML="Test demo: "+s;s=s-1;
            if (0 > s) {
                window.location="https://stackoverflow.com/a/13013464/1765658";
            }
            else window.setTimeout(cntdwn,1000);
        };
        window.onload=cntdwn;
        window.open("http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg","clock","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=400,top=36,left=700");                                     
        window.open("https://stackexchange.com/users/flair/1965184.png","netrate","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=208,height=58,top=36,left=490");
        </script>  </body>
eof
)"

或者甚至:(

$ firefox 'data:text/html;charset=ISO-8859-1;base64,PGh0bWw+PGhlYWQ+PHRpdGxlPlRF
U1QgRGVtbzwvdGl0bGU+PC9oZWFkPjxib2R5PjxoMyBpZD0idGl0bGUiPlRlc3QgZGVtbzwvaDM+PHNj
cmlwdCBsYW5ndWFnZT0iamF2YXNjcmlwdCI+d2luZG93Lm9wZW4oImh0dHA6Ly9wZXJzby5mLWhhdXJp
LmNoL35mZWxpeC9zdmcvZHVzdGluX3dfQ2xvY2tfYXV0b25vbS5zdmciLCJjbG9jayIsInRvb2xiYXI9
MCxsb2NhdGlvbj0wLHN0YXR1cz0wLG1lbnViYXI9MCxzY3JvbGxiYXJzPTEscmVzaXphYmxlPTEsd2lk
dGg9NDAwLGhlaWdodD00MDAsdG9wPTM2LGxlZnQ9NzAwIik7d2luZG93Lm9wZW4oImh0dHBzOi8vc3Rh
Y2tleGNoYW5nZS5jb20vdXNlcnMvZmxhaXIvMTk2NTE4NC5wbmciLCJuZXRyYXRlIiwidG9vbGJhcj0w
LGxvY2F0aW9uPTAsc3RhdHVzPTAsbWVudWJhcj0wLHNjcm9sbGJhcnM9MCxyZXNpemFibGU9MCx3aWR0
aD0yMDgsaGVpZ2h0PTU4LHRvcD0zNixsZWZ0PTQ5MCIpO3ZhciBzPTEwO2Z1bmN0aW9uIGNudGR3bigp
e2RvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJ0aXRsZSIpLmlubmVySFRNTD0iVGVzdCBkZW1vOiAiK3M7
cz1zLTE7aWYgKDAgPiBzKXt3aW5kb3cubG9jYXRpb249Imh0dHBzOi8vc3RhY2tvdmVyZmxvdy5jb20v
YS8xMzAxMzQ2NC8xNzY1NjU4Ijt9ZWxzZSB3aW5kb3cuc2V0VGltZW91dChjbnRkd24sMTAwMCk7fTt3
aW5kb3cub25sb2FkPWNudGR3bjs8L3NjcmlwdD48L2JvZHk+'

注意将Base64分割为4个字符的倍数!)

这与chromium相同,我相信,几乎每个浏览器......

编辑2023:解决方法阻止顶级数据:

出于安全原因,从版本 57 开始,Firefox 不再打开此类链接。运行此命令行只会打开一个新窗口,并将整个 data:... 链接放入 location 字段中。

我必须在新的 Firefox 窗口中点击:

  • Ctrl+l 来聚焦 location 字段,
  • Return 强制 Firefox 打开 data:... 链接。

然后

  • Alt+p 用于激活 preferences 按钮,最后
  • p 告诉 firefox :我们可以打开弹出窗口

为了自动执行此操作,我使用 xdotool (和 xwininfo,位于 )。

(当然,我可以转到 about:config,然后将 security.data_uri.block_toplevel_data_uri_navigations 设置为 security.data_uri.block_toplevel_data_uri_navigations >false,但我认为这是一个坏主意!)

#!/bin/bash

title='Inline html demos ( bash + javascript )'
targetUrl='https://stackoverflow.com/a/13013464/1765658'

declare -A urls='(
  [clock]="http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg"
  [flair]="https://stackexchange.com/users/flair/1965184.png"
)'
declare -A sizes='(  # " Left, Top, Width, Height, Resizeable (bool) "
  [clock]="               700,  36,   400,    400,          1 "
  [flair]="               490,  36,   208,     58,          0 "
)'
renderHtml() {
    cat <<-eof
        <html>        
          <body><h3>$title</h3><div id="title">[ . . . ]</div>
            <script type='text/javascript'>//<![CDATA[ 
            var s=10;
            function cntdwn() {
                document.getElementById("title").innerHTML="Countdown: "+s;
                s=s-1;
                if (0 > s) {
                  window.location="$targetUrl"
                }
                else window.setTimeout(cntdwn,1000);
            };
            function popwin(url,name,x, y, w, h, r) {
               var optns=["toolbar=0", "location=0", "status=0", "menubar=0",
                  "scrollbars=" + r, "resizable=" + r, "width=" + w, "height=" +
                  h, "top=" + y, "left=" + x].join(",");
               window.open(url,name,optns);
            };
            window.onload=cntdwn;
eof
    for topop in "${!urls[@]}"; do
        printf 'popwin("%s","%s",%s);\n' "${urls[$topop]}" \
            "$topop" "${sizes[$topop]}"
    done
    echo 
firefox 'data:text/html;base64,'"$(renderHtml|base64|tr -d \\n)" &

# Workaround 'security.data_uri.block_toplevel_data_uri_navigations=true'
exec {dummySleep}<> <(:)
for ((i=2500; i--; 1)); do   # Wait 5 secondes for new Firefox window.
    { read -r _; read -r _{,,,} wintitl
    } < <(xwininfo -id "$(xdotool getactivewindow)")
    case ${wintitl//\"} in Firefox*|Mozilla\ Firefox*) break ;; esac
    read -ru $dummySleep -t .002 _
done
read -ru $dummySleep -t .1 _
xdotool key --delay 200 Ctrl+l Return
read -ru $dummySleep -t .2 _
xdotool key --delay 200 Alt+p p

这个脚本可能会变得有用......只需根据您的需要编辑第一部分。

\n//]]>\n </script>\n</body>' }

这个脚本可能会变得有用......只需根据您的需要编辑第一部分。

Edit 2023, workaround Block toplevel data: see further!

Run firefox extras from command-line.

You could do many complex thing from comand line as running inline javascript (I've posted a Color RGB shower using firefox 'data:text/html.. under Another approach, at bottom of answer).

Maybe this could help you:

$ firefox 'data:text/html;charset=ISO-8859-1,
<html>
<head>
<title>TEST Demo</title>
</head>
<body>
<h3 id="title">Test demo</h3>
<script language="javascript">
window.open("http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg","clock","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=400,top=36,left=700");                                     
window.open("https://stackexchange.com/users/flair/1965184.png","netrate","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=208,height=58,top=36,left=490");
var s=10;                                                                 
function cntdwn()                                          
{                                                                 
  document.getElementById("title").innerHTML="Test demo: "+s;s=s-1;
  if (0 > s)                                                      
  {                                                                      
    window.location="https://stackoverflow.com/a/13013464/1765658";
  }                                                                      
  else window.setTimeout(cntdwn,1000);
  };                                        
  window.onload=cntdwn;
 </script>
 </body>'

This could be written:

$ firefox 'data:text/html;charset=ISO-8859-1,<html><body><h3 id="title"></h3>'"$(
    cat <<eof
        <script language="javascript">
        var s=10;
        function cntdwn() {
            document.getElementById("title").innerHTML="Test demo: "+s;s=s-1;
            if (0 > s) {
                window.location="https://stackoverflow.com/a/13013464/1765658";
            }
            else window.setTimeout(cntdwn,1000);
        };
        window.onload=cntdwn;
        window.open("http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg","clock","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=400,top=36,left=700");                                     
        window.open("https://stackexchange.com/users/flair/1965184.png","netrate","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=208,height=58,top=36,left=490");
        </script>  </body>
eof
)"

Or even:

$ firefox 'data:text/html;charset=ISO-8859-1;base64,PGh0bWw+PGhlYWQ+PHRpdGxlPlRF
U1QgRGVtbzwvdGl0bGU+PC9oZWFkPjxib2R5PjxoMyBpZD0idGl0bGUiPlRlc3QgZGVtbzwvaDM+PHNj
cmlwdCBsYW5ndWFnZT0iamF2YXNjcmlwdCI+d2luZG93Lm9wZW4oImh0dHA6Ly9wZXJzby5mLWhhdXJp
LmNoL35mZWxpeC9zdmcvZHVzdGluX3dfQ2xvY2tfYXV0b25vbS5zdmciLCJjbG9jayIsInRvb2xiYXI9
MCxsb2NhdGlvbj0wLHN0YXR1cz0wLG1lbnViYXI9MCxzY3JvbGxiYXJzPTEscmVzaXphYmxlPTEsd2lk
dGg9NDAwLGhlaWdodD00MDAsdG9wPTM2LGxlZnQ9NzAwIik7d2luZG93Lm9wZW4oImh0dHBzOi8vc3Rh
Y2tleGNoYW5nZS5jb20vdXNlcnMvZmxhaXIvMTk2NTE4NC5wbmciLCJuZXRyYXRlIiwidG9vbGJhcj0w
LGxvY2F0aW9uPTAsc3RhdHVzPTAsbWVudWJhcj0wLHNjcm9sbGJhcnM9MCxyZXNpemFibGU9MCx3aWR0
aD0yMDgsaGVpZ2h0PTU4LHRvcD0zNixsZWZ0PTQ5MCIpO3ZhciBzPTEwO2Z1bmN0aW9uIGNudGR3bigp
e2RvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJ0aXRsZSIpLmlubmVySFRNTD0iVGVzdCBkZW1vOiAiK3M7
cz1zLTE7aWYgKDAgPiBzKXt3aW5kb3cubG9jYXRpb249Imh0dHBzOi8vc3RhY2tvdmVyZmxvdy5jb20v
YS8xMzAxMzQ2NC8xNzY1NjU4Ijt9ZWxzZSB3aW5kb3cuc2V0VGltZW91dChjbnRkd24sMTAwMCk7fTt3
aW5kb3cub25sb2FkPWNudGR3bjs8L3NjcmlwdD48L2JvZHk+'

(Care to split Base64 by multiple of 4 chars!)

This work same with chromium and, I believe, near every browser...

Edit 2023: workaround Block toplevel data:

For security reason, from version 57, firefox doesn't no open this kind of links anymore. Running this command line will just open a new window and put the entire data:... link into location field.

I will have to hit in the new firefox window:

  • Ctrl+l for focusing location field,
  • Return for forcing firefox to open data:... link.

Then

  • Alt+p for activating preferences button, and finally
  • p to tell firefox: we are ok to open popups.

For doing this automatically, I use xdotool (and xwininfo, under ).

( Of course, I could go to about:config, then set security.data_uri.block_toplevel_data_uri_navigations to false, but I think this is a bad idea! )

#!/bin/bash

title='Inline html demos ( bash + javascript )'
targetUrl='https://stackoverflow.com/a/13013464/1765658'

declare -A urls='(
  [clock]="http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg"
  [flair]="https://stackexchange.com/users/flair/1965184.png"
)'
declare -A sizes='(  # " Left, Top, Width, Height, Resizeable (bool) "
  [clock]="               700,  36,   400,    400,          1 "
  [flair]="               490,  36,   208,     58,          0 "
)'
renderHtml() {
    cat <<-eof
        <html>        
          <body><h3>$title</h3><div id="title">[ . . . ]</div>
            <script type='text/javascript'>//<![CDATA[ 
            var s=10;
            function cntdwn() {
                document.getElementById("title").innerHTML="Countdown: "+s;
                s=s-1;
                if (0 > s) {
                  window.location="$targetUrl"
                }
                else window.setTimeout(cntdwn,1000);
            };
            function popwin(url,name,x, y, w, h, r) {
               var optns=["toolbar=0", "location=0", "status=0", "menubar=0",
                  "scrollbars=" + r, "resizable=" + r, "width=" + w, "height=" +
                  h, "top=" + y, "left=" + x].join(",");
               window.open(url,name,optns);
            };
            window.onload=cntdwn;
eof
    for topop in "${!urls[@]}"; do
        printf 'popwin("%s","%s",%s);\n' "${urls[$topop]}" \
            "$topop" "${sizes[$topop]}"
    done
    echo 
firefox 'data:text/html;base64,'"$(renderHtml|base64|tr -d \\n)" &

# Workaround 'security.data_uri.block_toplevel_data_uri_navigations=true'
exec {dummySleep}<> <(:)
for ((i=2500; i--; 1)); do   # Wait 5 secondes for new Firefox window.
    { read -r _; read -r _{,,,} wintitl
    } < <(xwininfo -id "$(xdotool getactivewindow)")
    case ${wintitl//\"} in Firefox*|Mozilla\ Firefox*) break ;; esac
    read -ru $dummySleep -t .002 _
done
read -ru $dummySleep -t .1 _
xdotool key --delay 200 Ctrl+l Return
read -ru $dummySleep -t .2 _
xdotool key --delay 200 Alt+p p

This script could comming to become usefull... Just edit 1st part for your need.

\n//]]>\n </script>\n</body>' }

This script could comming to become usefull... Just edit 1st part for your need.

一紙繁鸢 2024-08-14 22:25:30

附加组件无法“运行”(例如,从命令行运行 Adblock 意味着什么?)。

如果您使用的附加组件不支持命令行参数。您可以编写一个检查命令行的扩展并调用任何其他添加的适当函数-你想“跑”。

Add-ons can't be "run" (what does it mean to run Adblock from command line, for example?).

If the add-ons you're using do not support command-line params. you can write an extension that checks the command line and calls an appropriate function of the whatever other add-on you want to "run".

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