-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated React and added Dark Reader detection
- Loading branch information
1 parent
4bac032
commit 64c38c5
Showing
20 changed files
with
1,356 additions
and
1,812 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import _ from "lodash"; | ||
import { useCallback, useEffect } from "react"; | ||
import { Modals } from "./Modals"; | ||
|
||
let hasShown = false; | ||
export default function DarkReaderDetector() { | ||
const openDarkReaderNotice = useCallback(_.debounce(() => { | ||
if (hasShown) return; | ||
hasShown = true; | ||
|
||
Modals.push( | ||
<div | ||
className="BaseModal DarkReaderNoticeModal" | ||
style={{ | ||
background: "var(--primary-bg)", | ||
padding: 20 | ||
}} | ||
> | ||
<style> | ||
{"h1 { margin-top: 0; }"} | ||
</style> | ||
|
||
<h1>Dark reader detected!</h1> | ||
|
||
<p> | ||
This website is already respectful to your eyes, and Dark Reader may ruin the intended experience. Please disable dark reader on this site to see its intended design. | ||
</p> | ||
|
||
<h1>How?</h1> | ||
|
||
<p> | ||
Navigate to your extensions, and click the Dark Reader icon. | ||
</p> | ||
|
||
<img src="https://i.imgur.com/W6sxhj4.png" alt="1" /> | ||
|
||
<p> | ||
Then press the site URI at the top-left, this will disable for only this website, keeping your eyes safe on other websites. | ||
</p> | ||
|
||
<img src="https://i.imgur.com/3ENgzRS.png" alt="2" /> | ||
</div> | ||
) | ||
}, 200), []); | ||
|
||
const checkForDarkReader = useCallback(() => { | ||
const [html] = document.getElementsByTagName("html"); | ||
|
||
if (Object.values(html.attributes).some(attr => attr.localName.startsWith("data-darkreader"))) { | ||
openDarkReaderNotice(); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
checkForDarkReader(); | ||
|
||
const observer = new MutationObserver(() => { | ||
checkForDarkReader(); | ||
}); | ||
|
||
observer.observe(document.getElementsByTagName("html")[0], { attributes: true }); | ||
return () => observer.disconnect(); | ||
}, []); | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Dropdown, { DropdownItem } from "../Dropdown"; | ||
|
||
export const OrderTypes = { | ||
Default: "", | ||
Random: "order:random", | ||
Score: "order:score", | ||
FavCount: "order:favcount", | ||
TagCount: "order:tagcount", | ||
NewestFirst: "order:id_desc", | ||
OldestFirst: "order:id", | ||
Resolution: "order:mpixels", | ||
FileSize: "order:filesize" | ||
}; | ||
|
||
export default function OrderDropdown({ onChange }) { | ||
return ( | ||
<div className="Order FlexCenter"> | ||
<h2 className="Label">Order</h2> | ||
|
||
<Dropdown onChange={onChange}> | ||
{Object.keys(OrderTypes).map(key => ( | ||
<DropdownItem key={key} value={OrderTypes[key]}>{key}</DropdownItem> | ||
))} | ||
</Dropdown> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.