From 2a8f6e8cc42210bdd96585077c2dbfa50e250e92 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 20 Aug 2015 01:25:22 -0700 Subject: [PATCH] Make test for using Pale Moon workaround stricter. --- src/General/lib/$.coffee | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index c456b8bd5..2dcc822e9 100755 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -226,23 +226,24 @@ $.event = (event, detail, root=d) -> <% if (type === 'userscript') { %> # XXX Make $.event work in Pale Moon with GM 3.x (no cloneInto function). -unless typeof cloneInto is 'function' or /^[01]\./.test(GM_info.version) or GM_info.scriptHandler # not FF30+, GM1-, or Tampermonkey - do -> - try - new CustomEvent 'x', detail: {} - catch err - unsafeConstructors = - Object: unsafeWindow.Object - Array: unsafeWindow.Array - clone = (obj) -> - if obj? and typeof obj is 'object' and (constructor = unsafeConstructors[obj.constructor.name]) - obj2 = new constructor() - obj2[key] = clone val for key, val of obj - obj2 - else - obj - $.event = (event, detail, root=d) -> - root.dispatchEvent new CustomEvent event, {bubbles: true, detail: clone detail} +do -> + return unless /PaleMoon\//.test(navigator.userAgent) and +GM_info?.version?.split('.')[0] >= 2 and typeof cloneInto is 'undefined' + + try + new CustomEvent 'x', detail: {} + catch err + unsafeConstructors = + Object: unsafeWindow.Object + Array: unsafeWindow.Array + clone = (obj) -> + if obj? and typeof obj is 'object' and (constructor = unsafeConstructors[obj.constructor.name]) + obj2 = new constructor() + obj2[key] = clone val for key, val of obj + obj2 + else + obj + $.event = (event, detail, root=d) -> + root.dispatchEvent new CustomEvent event, {bubbles: true, detail: clone detail} <% } %> $.open =