From 8e3517735ee0968e36f983332ed295f4a7075269 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 5 Dec 2018 20:12:54 -0800 Subject: [PATCH] Don't allow bad siteProperties value to turn off script on 4chan. --- src/main/Main.coffee | 11 ++--------- src/site/Site.coffee | 6 ++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 1f820327a..6007b719a 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -67,10 +67,7 @@ Main = Conf['cooldowns'] = {} Conf['Index Sort'] = {} Conf["Last Long Reply Thresholds #{i}"] = {} for i in [0...2] - Conf['siteProperties'] = - '4chan.org': {software: 'yotsuba'} - '4channel.org': {software: 'yotsuba'} - '4cdn.org': {software: 'yotsuba'} + Conf['siteProperties'] = {} # XXX old key names Conf['Except Archives from Encryption'] = false @@ -80,11 +77,7 @@ Main = Conf['QR Shortcut'] = true Conf['Bottom QR Link'] = true Conf['Toggleable Thread Watcher'] = true - Conf['siteSoftware'] = """ - 4chan.org yotsuba - 4channel.org yotsuba - 4cdn.org yotsuba - """ + Conf['siteSoftware'] = '' # Enforce JS whitelist if /\.4chan(?:nel)?\.org$/.test(location.hostname) and !$$('script:not([src])', d).filter((s) -> /this\[/.test(s.textContent)).length diff --git a/src/site/Site.coffee b/src/site/Site.coffee index b33658864..4e2f0edea 100644 --- a/src/site/Site.coffee +++ b/src/site/Site.coffee @@ -1,5 +1,11 @@ Site = + defaultProperties: + '4chan.org': {software: 'yotsuba'} + '4channel.org': {software: 'yotsuba'} + '4cdn.org': {software: 'yotsuba'} + init: (cb) -> + $.extend Conf['siteProperties'], Site.defaultProperties {hostname} = location while hostname and hostname not of Conf['siteProperties'] hostname = hostname.replace(/^[^.]*\.?/, '')