Error: Permission denied to access property 'handler'

后端 未结 3 1437
春和景丽
春和景丽 2020-11-29 12:30

I have a greasemonkey script for Firefox, which yesterday was working perfectly. I tried using it today (no code was modified) and I noticed that it stopped working. Upon fu

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 12:57

    Greasemonkey 2.0 has just been pushed to all Firefox browsers set to auto-update. (GM 2 was released on June 17, 2014, but it can take a few weeks to get through the review process.)

    Greasemonkey 2.0 radically changed unsafeWindow handling:

    Backwards incompatible changes:

    • For stability, reliability, and security the privileged sandbox has been updated to match the new changes to unsafeWindow for the Add-on SDK. In order to write values to unsafeWindow you will need to use the new methods cloneInto(), exportFunction(), and/or createObjectIn().
    • The @grant none mode is now the default, and grants will no longer be implied when not explicitly provided. See the post Sandbox API Changes in Greasemonkey 2.0 for more detail.

    Ordinarily, to spot-access a page function or variable, you could switch to the new methods but, in your case you are using var $ = unsafeWindow.jQuery; -- which was always a bad practice.

    jQuery is a special case and cloning it back and forth is going to break things.
    @require jQuery instead, EG:

    // ==UserScript==
    // @name        _YOUR_SCRIPT_NAME
    // @include     http://YOUR_SERVER.COM/YOUR_PATH/*
    // @require     http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
    // @grant       GM_getResourceText
    // @grant       GM_addStyle
    // @grant       GM_xmlhttpRequest
    // @grant       GM_getResourceURL
    // ==/UserScript==
    ...
    

提交回复
热议问题