简体   繁体   English

事件“加载”的Opera用户脚本并不总是有效

[英]Opera userscript for event “load” doesn't always work

I have the following user javascript in opera: 我在opera中有以下用户javascript:

window.addEventListener( 
  'load', 
  function (e) { 
    document.title += " [MY loaded]"; 
 }, false);

I just want to change the title after it finishes loading the page, so that I know it's done. 我只想在完成加载页面后更改标题,以便我知道它已完成。 The title will be monitored by another script. 标题将由另一个脚本监视。 My problem is that some pages finish loading but the title is not changed, and I have no idea why or how to fix it. 我的问题是一些页面完成加载但标题没有改变,我不知道为什么或如何解决它。 Example: 例:

https://docs.google.com/a/dirus.org/spreadsheet/viewform https://docs.google.com/a/dirus.org/spreadsheet/viewform

Which gives me a "page not found" but the script apparently isn't triggered. 这给了我一个“找不到页面”,但剧本显然没有被触发。

EDIT: The code received by the browser apparently is not related to the problem, as the title gets correctly modified when loading the following page, that gives me a 404: 编辑:浏览器收到的代码显然与问题无关,因为在加载下一页时标题被正确修改,这给了我404:

http://50-118-237-24.gci.net/webscr.uk/page.html http://50-118-237-24.gci.net/webscr.uk/page.html

The problem is that userscripts don't run by default on HTTPS pages. 问题是HTTPS脚本默认情况下不会运行用户脚本。 According to Opera documentation at http://www.opera.com/docs/userjs/using/ : 根据http://www.opera.com/docs/userjs/using/上的Opera文档:

User JavaScript will not be loaded on pages accessed using the opera: protocol. 用户JavaScript不会加载到使用opera:protocol访问的页面上。 By default, it is also not loaded on pages accessed using the HTTPS: protocol. 默认情况下,它也不会加载到使用HTTPS:协议访问的页面上。

The solution to the problem is a bit further below in the documentation: 该问题的解决方案在文档中进一步说明如下:

If you want to run User JavaScripts on these pages, you will need to enable the User Javascript on HTTPS setting in opera:config. 如果要在这些页面上运行User JavaScripts,则需要在opera:config中启用HTTPS上的User Javascript设置。

Thanks Ian for the support. 谢谢伊恩的支持。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM