书签以在Android上的Firefox中激活阅读器模式 [英] Bookmarklet to activate reader mode in Firefox on Android
问题描述
最近,Android上的Firefox发生了变化,这使我无法使用将内容添加到阅读列表中并从中打开内容以迫使页面进入阅读器模式的工作.考虑到这一点,我试图找到一个书签,然后最终使它成为我的一个页面,以强制页面进入阅读器模式.
到目前为止,我发现通过在URL的开头添加'about:reader?url ='可以尝试将任何页面打开到阅读器模式.从那时起,我对javascript的了解并不多,因此我尝试使用我在网络上找到的其他示例来将某些东西混在一起.首先,我只是想出了如何添加到URL并能够使之工作
javascript:window.location = window.location +'about:reader?url =';
上面的内容可以很好地添加到末尾,但是当我将其移到开头时,它将不再起作用
javascript:window.location ='about:reader?url ='+ window.location;
即使在仅允许阅读器模式的页面上也没有任何反应.当我用测试"替换我要添加的内容时,尽管它会很高兴地导致页面转到测试http://www.google.com/"或其他任何地方.我不仅在我的android手机上,而且在我的桌面上都尝试过它.从我可以看到的结果来看,我在做什么错了?
几乎可以肯定,Firefox认为允许Javascript将页面更改为以 about:
开头的任何位置都存在安全风险./p>
在Windows的Firefox中使用Javascript控制台运行此代码:
window.location ='about:reader?url ='+ window.location;
返回错误:
无法从脚本访问'about:reader?url = ...'
这是一种解决方法",可以减轻您的特殊痛苦:
javascript:(function(){prompt('复制以下文本,然后将其粘贴到URL栏中:','about:reader?url ='+ encodeURIComponent(document.location))})();
它将提示您一个URL,您可以复制该URL,然后将其粘贴到URL栏中.
Recently a change happened with Firefox on Android which stopped me from using the work around of adding something to my reading list and opening it from there to force a page into reader mode. With that in mind I tried to find and then finally make a bookmarklet to force a page into reader mode for me.
So far I have found that by adding 'about:reader?url=' to the beginning of a url will try to open any page into reader mode. From there not knowing much about javascript I tried to cludge together something using other examples I found on the web. To start I just figured out how to add to the url and was able to get that working
javascript: window.location = window.location + 'about:reader?url=';
The above will add onto the end just fine but when I move it to the beginning it no longer works so when I try
javascript: window.location = 'about:reader?url=' + window.location;
Nothing happens at all even on a page that will just allow reader mode. When I replace the stuff I am adding with just 'test' though it will happily cause the page to go to 'testhttp://www.google.com/' or wherever else. I have tried it on not only my android phone but also my desktop. What am I doing wrong as from what I can see this should work?
Almost certainly Firefox considers it to be a security risk to allow Javascript to change a page to any location beginning with about:
.
Using the Javascript console in Firefox in Windows to run this code:
window.location = 'about:reader?url=' + window.location;
returns error:
Access to 'about:reader?url=...' from script denied
Here is a "work around" that might ease your particular pain:
javascript:(function(){prompt('Copy the below text and then paste it into the URL bar:', 'about:reader?url='+encodeURIComponent(document.location))})();
It will prompt you with a url you can copy and then paste into the URL bar.
这篇关于书签以在Android上的Firefox中激活阅读器模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!