Repository: darkreader/darkreader
Pull request #883 (2018-12-05 18:46:21)

docs(fix): relatve anchor url for contributors


Patch:
diff --git a/README.md b/README.md
index 21eed86f..0f94fadc 100644
--- a/README.md
+++ b/README.md
@@ -122,7 +122,7 @@ Submit a **pull request**, wait for **review**.
 
 This project exists thanks to all the people who contribute
 
-<a href="graphs/contributors"><img src="https://opencollective.com/darkreader/contributors.svg?width=890&button=false" /></a>
+<a href="../../graphs/contributors"><img src="https://opencollective.com/darkreader/contributors.svg?width=890&button=false" /></a>
 
 ## Backers
 
diff --git a/src/config/dark-sites.config b/src/config/dark-sites.config
index 45432e87..e38864db 100644
--- a/src/config/dark-sites.config
+++ b/src/config/dark-sites.config
@@ -54,6 +54,7 @@ gogoanime.se
 greenmangaming.com
 gunshipmusic.com
 hackaday.com
+hackersforcharity.org
 hackertyper.com
 hardcoregaming101.net
 heapmedia.com
@@ -111,6 +112,7 @@ vakhtangov.ru
 vinesauce.com
 visualboxsite.com
 vuecinemas.nl
+w0rp.com
 weboas.is
 www.directvnow.com
 www.gdax.com
diff --git a/src/config/dynamic-theme-fixes.config b/src/config/dynamic-theme-fixes.config
index d919e299..f2801915 100644
--- a/src/config/dynamic-theme-fixes.config
+++ b/src/config/dynamic-theme-fixes.config
@@ -104,6 +104,15 @@ img
 
 ================================
 
+fivethirtyeight.com
+
+INVERT
+.site-logo
+#searchform
+.header-espn-link
+
+================================
+
 gitlab.com
 
 INVERT
@@ -137,6 +146,14 @@ img[src*="//tex.s2cms.ru/"]
 
 ================================
 
+hdgo.cc
+
+INVERT
+.hdplayer .big_play_button div
+.hdplayer .hdgo_controls div.hdgo_pause_control div
+
+================================
+
 inbox.google.com
 
 INVERT
@@ -145,6 +162,14 @@ nav li img
 
 ================================
 
+instagram.com
+
+INVERT
+.Igw0E.rBNOH.eGOV_.ybXk5._4EzTm
+._47KiJ
+
+================================
+
 keep.google.com
 
 INVERT
@@ -157,9 +182,21 @@ INVERT
 
 ================================
 
+mastarti.com
+
+INVERT
+.fp-play-icon div
+.fp-pause-icon .fp-pause-block div
+.fp-volumebar em.fp-color
+.fp-fullscreen-line
+.fp-fullscreen-dot
+
+================================
+
 medium.com
 
 INVERT
+.svgIcon
 .svgIcon-use
 
 ================================
@@ -188,6 +225,16 @@ INVERT
 
 ================================
 
+nzbget.*
+
+INVERT
+.icon-top
+.icon-bottom
+.icon-up
+.icon-down
+
+================================
+
 producthunt.com
 
 INVERT
diff --git a/src/config/inversion-fixes.config b/src/config/inversion-fixes.config
index 0ec4aeb8..4fa4b4df 100644
--- a/src/config/inversion-fixes.config
+++ b/src/config/inversion-fixes.config
@@ -1497,6 +1497,13 @@ img
 
 ================================
 
+regexr.com
+
+INVERT
+canvas.highlights
+
+================================
+
 rijnijssel.elo.education-online.nl
 
 NO INVERT
diff --git a/src/inject/dynamic-theme/style-manager.ts b/src/inject/dynamic-theme/style-manager.ts
index c5bd9506..dcd119e5 100644
--- a/src/inject/dynamic-theme/style-manager.ts
+++ b/src/inject/dynamic-theme/style-manager.ts
@@ -361,9 +361,9 @@ export function manageStyle(element: HTMLLinkElement | HTMLStyleElement, {update
             syncStylePositionWatcher = watchForNodePosition(syncStyle);
         }
 
-        function onAsyncDeclarationReady(key: number) {
+        function onAsyncDeclarationReady(key: number, currentRenderId: number) {
             asyncQueue.add(key);
-            rebuildAsyncRules();
+            throttledRebuildAsyncRules(currentRenderId);
         }
 
         function rebuildAsyncRules() {
@@ -390,17 +390,12 @@ export function manageStyle(element: HTMLLinkElement | HTMLStyleElement, {update
             asyncQueue.clear();
         }
 
-        const RULES_PER_MS = 100;
-        const REQUESTED_RESOURCES = 1 / 4;
-        const declarationsCount = modRules.filter((r) => r).reduce((total, {declarations}) => total + declarations.length, 0);
-        const timeout = declarationsCount / RULES_PER_MS / REQUESTED_RESOURCES;
-
-        const throttledBuildStyleSheet = throttle((currentRenderId: number) => {
+        const throttledRebuildAsyncRules = throttle((currentRenderId: number) => {
             if (cancelAsyncOperations || renderId !== currentRenderId) {
                 return;
             }
-            buildStyleSheet();
-        }, timeout);
+            rebuildAsyncRules();
+        });
 
         modRules.filter((r) => r).forEach(({selector, declarations, media}) => {
             declarations.forEach(({property, value, important}) => {
@@ -417,7 +412,7 @@ export function manageStyle(element: HTMLLinkElement | HTMLStyleElement, {update
                                 return;
                             }
                             readyDeclarations[index].value = asyncValue;
-                            onAsyncDeclarationReady(asyncKey);
+                            onAsyncDeclarationReady(asyncKey, currentRenderId);
                         });
                     } else {
                         readyDeclarations.push({media, selector, property, value: modified, important});
@@ -428,7 +423,7 @@ export function manageStyle(element: HTMLLinkElement | HTMLStyleElement, {update
             });
         });
 
-        throttledBuildStyleSheet(renderId);
+        buildStyleSheet();
     }
 
     let rulesCount: number = null;
diff --git a/src/inject/dynamic-theme/watch.ts b/src/inject/dynamic-theme/watch.ts
index bc7f2795..bb26fa5d 100644
--- a/src/inject/dynamic-theme/watch.ts
+++ b/src/inject/dynamic-theme/watch.ts
@@ -60,7 +60,13 @@ export function watchForStyleChanges(update: (styles: ChangedStyles) => void) {
             });
         }
 
-        iterateShadowNodes(mutations.reduce((nodes, m) => nodes.concat(Array.from(m.addedNodes)), []), subscribeForShadowRootChanges);
+        const allAddedNodes = [];
+        mutations.forEach((m) => {
+            m.addedNodes.forEach((n) => {
+                allAddedNodes.push(n);
+            });
+        });
+        iterateShadowNodes(allAddedNodes, subscribeForShadowRootChanges);
     }
 
     function subscribeForShadowRootChanges(node: Element) {
diff --git a/src/utils/time.ts b/src/utils/time.ts
index f0aababf..ebdbaf83 100644
--- a/src/utils/time.ts
+++ b/src/utils/time.ts
@@ -32,19 +32,19 @@ function compareTime(a: number[], b: number[]) {
         return 0;
     }
     if (a[0] < b[0] || (a[0] === b[0] && a[1] < b[1])) {
-        return 1;
+        return -1;
     }
-    return -1;
+    return 1;
 }
 
 export function isInTimeInterval(date: Date, time0: string, time1: string) {
-    const t0 = parse24HTime(time0);
-    const t1 = parse24HTime(time1);
+    const a = parse24HTime(time0);
+    const b = parse24HTime(time1);
     const t = [date.getHours(), date.getMinutes()];
-    if (compareTime(t0, t1) < 0) {
-        t0[0] -= 24;
+    if (compareTime(a, b) > 0) {
+        return compareTime(a, t) <= 0 || compareTime(t, b) < 0;
     }
-    return compareTime(t0, t) >= 0 && compareTime(t, t1) > 0;
+    return compareTime(a, t) <= 0 && compareTime(t, b) < 0;
 }
 
 interface Duration {


Test patch:
diff --git a/tests/time.tests.ts b/tests/time.tests.ts
index 488a0c08..95d1acd3 100644
--- a/tests/time.tests.ts
+++ b/tests/time.tests.ts
@@ -2,10 +2,15 @@ import {isInTimeInterval, parseTime, getDuration} from '../src/utils/time';
 
 test('Time interval', () => {
     expect(isInTimeInterval(new Date(2018, 11, 4, 10), '9:00', '12:00')).toBe(true);
+    expect(isInTimeInterval(new Date(2018, 11, 4, 10), '10:00', '10:00')).toBe(false);
+    expect(isInTimeInterval(new Date(2018, 11, 4, 12), '10:00', '10:00')).toBe(false);
+    expect(isInTimeInterval(new Date(2018, 11, 4, 8), '10:00', '10:00')).toBe(false);
     expect(isInTimeInterval(new Date(2018, 11, 4, 10), '9:00', '10:00')).toBe(false);
+    expect(isInTimeInterval(new Date(2018, 11, 4, 9, 2), '9:01', '10:00')).toBe(true);
     expect(isInTimeInterval(new Date(2018, 11, 4, 10), '9:00', '10:01')).toBe(true);
     expect(isInTimeInterval(new Date(2018, 11, 4, 10), '18:00', '12:00')).toBe(true);
     expect(isInTimeInterval(new Date(2018, 11, 4, 10), '18:00', '9:00')).toBe(false);
+    expect(isInTimeInterval(new Date(2018, 11, 4, 22), '18:00', '9:00')).toBe(true);
 });
 
 test('Time parse', () => {