diff --git a/public/fetchRelevantPicUrls.js b/public/fetchRelevantPicUrls.js
index bb4fadc..31a532d 100644
--- a/public/fetchRelevantPicUrls.js
+++ b/public/fetchRelevantPicUrls.js
@@ -1,6 +1,6 @@
/* global chrome*/
{
- chrome.storage.local.set({ pageUrl: window.location.href, parentPicUrl: [], childrenPageUrls: [] });
+ chrome.storage.local.set({ pageUrl: [window.location.href], parentPicUrl: [], childrenPageUrls: [] });
const divPostView = document.getElementById("post-view");
const divStatusNotice = Array.from(divPostView.getElementsByClassName("status-notice"));
for (let div of divStatusNotice) {
diff --git a/public/getChildPicObjs.js b/public/getChildPicObjs.js
deleted file mode 100644
index 737a533..0000000
--- a/public/getChildPicObjs.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/*global chrome*/
-
-{
- const image = document.getElementById("image");
- const pngLink = document.getElementById("png");
- const pngHref = pngLink ? pngLink.href : undefined;
- chrome.storage.local.set({
- childPic: {
- src: pngHref ?? image.src,
- extension: image.src.split(".").pop(),
- large_height: image.getAttribute("large_height"),
- large_width: image.getAttribute("large_width")
- }
- });
-}
diff --git a/public/getMainPicObj.js b/public/getMainPicObj.js
deleted file mode 100644
index 4d166be..0000000
--- a/public/getMainPicObj.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/*global chrome*/
-
-{
- const image = document.getElementById("image");
- const pngLink = document.getElementById("png");
- const pngHref = pngLink ? pngLink.href : "";
- chrome.storage.local.set({
- mainPic: {
- src: image.src,
- pngUrl: pngHref,
- extension: image.src.split(".").pop(),
- large_height: image.getAttribute("large_height"),
- large_width: image.getAttribute("large_width")
- }
- });
-}
diff --git a/public/getParentPicObj.js b/public/getParentPicObj.js
deleted file mode 100644
index b8c5120..0000000
--- a/public/getParentPicObj.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/*global chrome*/
-
-{
- const image = document.getElementById("image");
- chrome.storage.local.set({
- parentPic: {
- pageUrl: window.location.href,
- src: image.src,
- extension: image.src.split(".").pop(),
- large_height: image.getAttribute("large_height"),
- large_width: image.getAttribute("large_width")
- }
- });
-}
diff --git a/src/App.js b/src/App.js
index 3867020..ebf5b7b 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,15 @@
/*global chrome*/
import "./App.css";
import { useState, useEffect } from "react";
-import { fetchChildrenPics, fetchMainPic, fetchParentPic } from "./js/fetchRelevant";
-import { Stack, Container, Row, Col, Button, CardGroup } from "react-bootstrap";
+import { fetchRelevantPics } from "./js/fetchRelevant";
+import { Stack, Container, Row, Col, Button } from "react-bootstrap";
import { RelevantPicCardGroup } from "./components/RelevantPicCardGroup";
import { MainImageCard } from "./components/MainImageCard";
import { ModalComparison } from "./components/ModalComparison";
function App() {
const [mainPic, setMainPic] = useState();
- const [highQual, setHighQual] = useState("");
- const [parentPic, setParentPic] = useState([]);
+ const [parentPic, setParentPic] = useState();
const [childrenPics, setChildrenPics] = useState([]);
const [selected, setSelected] = useState([]);
const [showRelevant, setShowRelevant] = useState(false);
@@ -18,9 +17,20 @@ function App() {
useEffect(() => {
chrome.storage.local.get(["pageUrl", "parentPicUrl", "childrenPageUrls"], data => {
- fetchMainPic(data.pageUrl, setMainPic, setHighQual);
- setParentPic(fetchParentPic(data.parentPicUrl));
- setChildrenPics(fetchChildrenPics(data.childrenPageUrls));
+ fetchRelevantPics("main", data.pageUrl);
+ fetchRelevantPics("parent", data.parentPicUrl);
+ fetchRelevantPics("child", data.childrenPageUrls);
+ });
+ chrome.runtime.onMessage.addListener(message => {
+ if (message.mainPic) {
+ setMainPic(message.mainPic);
+ }
+ if (message.parentPic) {
+ setParentPic(message.parentPic);
+ }
+ if (message.childPic) {
+ setChildrenPics(oldList => [...oldList, message.childPic]);
+ }
});
}, []);
@@ -53,12 +63,7 @@ function App() {
-
+ {mainPic && }
diff --git a/src/components/ImageCard.js b/src/components/ImageCard.js
index 493972e..e36ace0 100644
--- a/src/components/ImageCard.js
+++ b/src/components/ImageCard.js
@@ -1,10 +1,9 @@
-/*global chrome*/
-
import { useState } from "react";
-import { Row, Col, Card, Button, Badge } from "react-bootstrap";
+import { Stack, Row, Col, Card, Button, Badge } from "react-bootstrap";
import { ModalPreview } from "./ModalPreview";
import { DownloadButton } from "./DownloadButton";
import { toggleSelected } from "../js/commonFunctions";
+import { fetchByPageUrl } from "../js/fetchRelevant";
export function ImageCard(props) {
const [showButtons, setShowButtons] = useState(false);
@@ -32,20 +31,34 @@ export function ImageCard(props) {
{showButtons && (
{props.isParent && (
-
+
)}
+ {!props.isParent && props.pic.hasDeeperRelatives && (
+
+
+
+
+ )}
+