From 53f2252f38252631b3e0510f0e5ab114a938079c Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 25 Jul 2019 18:49:57 -0700 Subject: [PATCH] Detect conflicts with native extension and show appropriate error message. #1627 --- src/main/Main.coffee | 11 +++++++++++ src/site/SW.yotsuba.coffee | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 93ded5a02..9b600b920 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -99,6 +99,7 @@ Main = # Fresh install else if !items.previousversion? + Main.isFirstRun = true Main.ready -> $.set 'previousversion', g.VERSION Settings.open() @@ -502,6 +503,16 @@ Main = new Notice 'error', 'Error: Multiple copies of 4chan X are enabled.' $.addClass doc, 'tainted' + # Detect conflicts with native extension + if g.SITE.testNativeExtension and not $.hasClass(doc, 'tainted') + {enabled} = g.SITE.testNativeExtension() + if enabled + $.addClass doc, 'tainted' + if Conf['Disable Native Extension'] and !Main.isFirstRun + msg = $.el 'div', + <%= html('Failed to disable the native extension. You may need to block it.') %> + new Notice 'error', msg + unless errors instanceof Array error = errors else if errors.length is 1 diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index 44521b85a..c29f51cfe 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -225,3 +225,7 @@ SW.yotsuba = isLinkified: (link) -> ImageHost.test(link.hostname) + + testNativeExtension: -> + $.global -> + @enabled = 'true' if window.Parser.postMenuIcon