Repository: darkreader/darkreader
Pull request #3592 (2020-09-04 11:14:18)

Fixed toggling PDF files


Patch:
diff --git a/package-lock.json b/package-lock.json
index b3f8ba56..aa54d4f3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "darkreader",
-  "version": "4.9.17",
+  "version": "4.9.18",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
diff --git a/package.json b/package.json
index 10416a18..63b756a1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "darkreader",
-  "version": "4.9.17",
+  "version": "4.9.18",
   "description": "Dark theme for every website",
   "scripts": {
     "api": "node tasks/build.js --api",
diff --git a/src/config/dynamic-theme-fixes.config b/src/config/dynamic-theme-fixes.config
index e0aa7329..904d7cac 100644
--- a/src/config/dynamic-theme-fixes.config
+++ b/src/config/dynamic-theme-fixes.config
@@ -1286,6 +1286,16 @@ video#vjs_video_3_html5_api.vjs-tech {
 
 ================================
 
+daum.net
+
+CSS
+.txt_pctop,
+.bg_login {
+    background-image: none !important;
+}
+
+================================
+
 debian.org
 
 CSS
@@ -3200,6 +3210,14 @@ INVERT
 
 ================================
 
+launchpad.net
+
+INVERT
+.edit-controls
+#launchpad-logo-and-name
+
+================================
+
 leetcode.com
 leetcode-cn.com
 
@@ -3346,6 +3364,14 @@ img {
 
 ================================
 
+m.dianping.com
+
+INVERT
+.flash-screen
+.header-download-img
+
+================================
+
 madshi.net
 
 CSS
@@ -4370,6 +4396,15 @@ body {
 
 ================================
 
+personal.vanguard.com
+
+CSS
+.hidePageIfJSdisabled {
+    display: block !important;
+}
+
+================================
+
 pgatour.com
 
 CSS
@@ -4441,6 +4476,13 @@ INVERT
 
 ================================
 
+portal.qiniu.com
+
+INVERT
+.global-loading-content img
+
+================================
+
 praca.money.pl
 
 CSS
@@ -4572,6 +4614,14 @@ CSS
 
 ================================
 
+qwant.com
+
+INVERT
+.background-home__logo
+.home__logo__container .home__logo
+
+================================
+
 rachel53461.wordpress.com
 
 CSS
@@ -6097,6 +6147,21 @@ INVERT
 
 ================================
 
+vbulletin.com
+
+CSS
+.std {
+    background-color: var(--darkreader-neutral-background) !important;
+}
+.hero-text,
+#hometext li,
+#hometext h4,
+#hometext_buttons div p {
+    color: var(--darkreader-neutral-background) !important;
+}
+
+================================
+
 vc.ru
 
 INVERT
diff --git a/src/manifest.json b/src/manifest.json
index 173f46c2..c45ab2fe 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,7 +1,7 @@
 {
     "manifest_version": 2,
     "name": "Dark Reader",
-    "version": "4.9.17",
+    "version": "4.9.18",
     "author": "Alexander Shutau",
     "description": "__MSG_extension_description__",
     "default_locale": "en",
diff --git a/src/ui/popup/components/site-toggle/checkmark-icon.tsx b/src/ui/popup/components/site-toggle/checkmark-icon.tsx
index 60b9bcc7..a8b20e5b 100644
--- a/src/ui/popup/components/site-toggle/checkmark-icon.tsx
+++ b/src/ui/popup/components/site-toggle/checkmark-icon.tsx
@@ -1,10 +1,10 @@
 import {m} from 'malevic';
 
-export default function CheckmarkIcon({isEnabled}) {
+export default function CheckmarkIcon({isChecked}) {
     return (
         <svg viewBox="0 0 8 8">
             <path
-                d={(isEnabled ?
+                d={(isChecked ?
                     'M1,4 l2,2 l4,-4 v1 l-4,4 l-2,-2 Z' :
                     'M2,2 l4,4 v1 l-4,-4 Z M2,6 l4,-4 v1 l-4,4 Z'
                 )} />
diff --git a/src/ui/popup/components/site-toggle/index.tsx b/src/ui/popup/components/site-toggle/index.tsx
index 3be71794..58720081 100644
--- a/src/ui/popup/components/site-toggle/index.tsx
+++ b/src/ui/popup/components/site-toggle/index.tsx
@@ -32,12 +32,12 @@ export default function SiteToggleButton({data, tab, actions}: ExtWrapper & {tab
         <Button
             class={{
                 'site-toggle': true,
-                'site-toggle--active': pdf ? data.settings.enableForPDF : isSiteEnabled,
+                'site-toggle--active': isSiteEnabled,
                 'site-toggle--disabled': !toggleHasEffect
             }}
             onclick={onSiteToggleClick}
         >
-            <span class="site-toggle__mark"><CheckmarkIcon isEnabled={isSiteEnabled} /></span>
+            <span class="site-toggle__mark"><CheckmarkIcon isChecked={isSiteEnabled} /></span>
             {' '}
             <span class="site-toggle__url" >{pdf ? 'PDF' : urlText}</span>
         </Button>
diff --git a/src/utils/url.ts b/src/utils/url.ts
index 3ffc5fb9..74345859 100644
--- a/src/utils/url.ts
+++ b/src/utils/url.ts
@@ -140,7 +140,7 @@ export function isURLEnabled(url: string, userSettings: UserSettings, {isProtect
     if (isProtected && !userSettings.enableForProtectedPages) {
         return false;
     }
-    if (isPDF(url) && userSettings.enableForPDF) {
+    if (isPDF(url)) {
         return userSettings.enableForPDF;
     }
     const isURLInUserList = isURLInList(url, userSettings.siteList);


Test patch:
diff --git a/tests/utils/url.tests.ts b/tests/utils/url.tests.ts
index 7ab7a334..ab969ca7 100644
--- a/tests/utils/url.tests.ts
+++ b/tests/utils/url.tests.ts
@@ -102,11 +102,21 @@ test('URL is enabled', () => {
         {siteList: ['darkreader.org'], siteListEnabled: [], applyToListedOnly: true} as UserSettings,
         {isProtected: false, isInDarkList: true},
     )).toBe(true);
+    expect(isURLEnabled(
+        'https://www.google.com/file.pdf',
+        {enableForPDF: true, siteList: ['darkreader.org'], siteListEnabled: [], applyToListedOnly: false} as UserSettings,
+        {isProtected: false, isInDarkList: false},
+    )).toBe(true);
     expect(isURLEnabled(
         'https://www.google.com/file.pdf',
         {enableForPDF: true, siteList: ['darkreader.org'], siteListEnabled: [], applyToListedOnly: true} as UserSettings,
         {isProtected: false, isInDarkList: false},
     )).toBe(true);
+    expect(isURLEnabled(
+        'https://www.google.com/file.pdf',
+        {enableForPDF: false, siteList: ['darkreader.org'], siteListEnabled: [], applyToListedOnly: false} as UserSettings,
+        {isProtected: false, isInDarkList: false},
+    )).toBe(false);
     expect(isURLEnabled(
         'https://www.google.com/file.pdf/resource',
         {enableForPDF: true, siteList: ['darkreader.org'], siteListEnabled: [], applyToListedOnly: true} as UserSettings,