jQuery in Greasemonkey 1.0 conflicts with websites using jQuery

前端 未结 3 2253
猫巷女王i
猫巷女王i 2020-11-22 05:07

Ever since the new Greasemonkey 1.0 was released a few days ago, every site that has jQuery and where I use jQuery in my Greasemonkey script do not run my script properly. T

3条回答
  •  遥遥无期
    2020-11-22 05:43

    Two years on and this "feature" still hasn't been sufficiently documented or addressed.

    Scripts which require jQuery still conflict with some pages which use jQuery.

    Potential solutions are:

    1. Add @grant GM_log or similar to sandbox the script
    2. Alias existing jQuery objects in the script by adding this block:

      var my_jquery = jQuery;

      jQuery.noConflict(true);

      var $ = my_jquery, jQuery = my_jquery;

    3. Don't use jQuery

    All in all, a terrible decision from Greasemonkey.

提交回复
热议问题