Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

CrowdWise is a Google Chrome extension that adds to your browsing experience by showing you relevant discussions about your current web page from Hacker News and Reddit.

[![Screenshot](assets/screenshot-1.jpeg)](https://chrome.google.com/webstore/detail/crowdwise/hogoebkpcnajkkjdidfhojkljppfalip)
<p align="center" >
<a href="https://chrome.google.com/webstore/detail/crowdwise/hogoebkpcnajkkjdidfhojkljppfalip">
<img src="assets/screenshot-1.png">
</a>
</p>

## Features

Expand Down
Binary file removed assets/screenshot-1.jpeg
Binary file not shown.
Binary file added assets/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions src/containers/HotkeysListenerButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from "lodash";
import React, { useState } from "react";

import { KEY_INCOGNITO_MODE } from "../shared/constants";
import { EventType, sendEventsToServerViaWorker } from "../shared/events";
import { useSettingsStore } from "../shared/settings";
import { useHotkeysPressed } from "../shared/useHotkeysPressed";
Expand All @@ -25,11 +26,14 @@ const HotkeysListenerButton = (props: Props) => {
] = useSettingsStore();
const setKeyValueWithEvents = (key: string, value: any) => {
setKeyValue(key, value);
sendEventsToServerViaWorker({
eventType: EventType.CHANGE_SETTING,
settingKey: key,
settingValue: value,
});
sendEventsToServerViaWorker(
{
eventType: EventType.CHANGE_SETTING,
settingKey: key,
settingValue: value,
},
settings[KEY_INCOGNITO_MODE]
);
};

// "+" and "," are special delimiters used by react-hotkeys-hook
Expand Down
45 changes: 27 additions & 18 deletions src/containers/ResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
COLOR_IF_OUTSIDE_HASH,
KEY_BOLD_INITIAL_CHARS_OF_WORDS,
KEY_FONT_SIZES,
KEY_INCOGNITO_MODE,
KEY_SHOULD_COLOR_FOR_SUBMITTED_BY,
} from "../shared/constants";
import { EventType, sendEventsToServerViaWorker } from "../shared/events";
Expand All @@ -21,22 +22,26 @@ interface Props {
const logForumResultEvent = (
eventType: EventType,
cardPosition: number,
result: ResultItem
result: ResultItem,
isIncognitoMode: boolean
) => {
sendEventsToServerViaWorker({
eventType,
resultCardPosition: cardPosition,
resultSubmittedUrl: result.submittedUrl,
resultSubmittedDate: result.submittedDate,
resultSubmittedUpvotes: result.submittedUpvotes,
resultSubmittedTitle: result.submittedTitle,
resultSubmittedBy: result.submittedBy,
resultSubmittedByLink: result.submittedByLink,
resultCommentsCount: result.commentsCount,
resultCommentsLink: result.commentsLink,
resultSubSourceName: result.subSourceName,
resultSubSourceLink: result.subSourceLink,
});
sendEventsToServerViaWorker(
{
eventType,
resultCardPosition: cardPosition,
resultSubmittedUrl: result.submittedUrl,
resultSubmittedDate: result.submittedDate,
resultSubmittedUpvotes: result.submittedUpvotes,
resultSubmittedTitle: result.submittedTitle,
resultSubmittedBy: result.submittedBy,
resultSubmittedByLink: result.submittedByLink,
resultCommentsCount: result.commentsCount,
resultCommentsLink: result.commentsLink,
resultSubSourceName: result.subSourceName,
resultSubSourceLink: result.subSourceLink,
},
isIncognitoMode
);
};

const ResultCard = (props: Props) => {
Expand All @@ -56,6 +61,7 @@ const ResultCard = (props: Props) => {

const boldInitialCharsOfWords = settings[KEY_BOLD_INITIAL_CHARS_OF_WORDS];
const fontSizes = settings[KEY_FONT_SIZES];
const isIncognitoMode = settings[KEY_INCOGNITO_MODE];
const colorForSubmittedBy = settings[KEY_SHOULD_COLOR_FOR_SUBMITTED_BY]
? hashStringToColor(result.submittedBy)
: COLOR_IF_OUTSIDE_HASH;
Expand All @@ -67,7 +73,8 @@ const ResultCard = (props: Props) => {
logForumResultEvent(
EventType.CLICK_SIDEBAR_FORUM_RESULT_TITLE,
cardPosition,
result
result,
isIncognitoMode
);
onCardClick(result.commentsLink);
}}
Expand All @@ -84,7 +91,8 @@ const ResultCard = (props: Props) => {
logForumResultEvent(
EventType.CLICK_SIDEBAR_FORUM_RESULT_SUB_SOURCE,
cardPosition,
result
result,
isIncognitoMode
);
e.stopPropagation();
}}
Expand All @@ -110,7 +118,8 @@ const ResultCard = (props: Props) => {
logForumResultEvent(
EventType.CLICK_SIDEBAR_FORUM_RESULT_TITLE,
cardPosition,
result
result,
isIncognitoMode
);
e.stopPropagation();
}}
Expand Down
20 changes: 12 additions & 8 deletions src/containers/SettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ export const SettingsPanel = (props: Props) => {
error,
isLoadingStore,
] = useSettingsStore();
const setKeyValueWithEvents = (key: string, value: any) => {
setKeyValue(key, value);
sendEventsToServerViaWorker({
eventType: EventType.CHANGE_SETTING,
settingKey: key,
settingValue: value,
});
};

const sideBarWidth = settings[KEY_SIDEBAR_WIDTH];
const sideBarOpacity = settings[KEY_SIDEBAR_OPACITY];
Expand All @@ -72,6 +64,18 @@ export const SettingsPanel = (props: Props) => {
settings[KEY_SHOULD_SHOW_SIDEBAR_ONLY_ON_EXACT_RESULTS];
const isIncognitoMode = settings[KEY_INCOGNITO_MODE];

const setKeyValueWithEvents = (key: string, value: any) => {
setKeyValue(key, value);
sendEventsToServerViaWorker(
{
eventType: EventType.CHANGE_SETTING,
settingKey: key,
settingValue: value,
},
isIncognitoMode
);
};

const setSideBarWidth = (state: number) =>
setKeyValueWithEvents(KEY_SIDEBAR_WIDTH, state);
const setSideBarOpacity = (state: number) =>
Expand Down
19 changes: 13 additions & 6 deletions src/pages/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const Sidebar = () => {
] = useSettingsStore();

const hotkeysToggleSidebar = settings[KEY_HOTKEYS_TOGGLE_SIDEBAR];
const isIncognitoMode = settings[KEY_INCOGNITO_MODE];

// Handles message from background script that our URL changed.
// We receive this message only when we are in a SPA and the link changes without full-page reload.
Expand Down Expand Up @@ -218,9 +219,12 @@ const Sidebar = () => {
<CogIcon
className="h-5 w-5 text-slate-500"
onClick={() =>
sendEventsToServerViaWorker({
eventType: EventType.CLICK_SIDEBAR_SETTING_ICON,
})
sendEventsToServerViaWorker(
{
eventType: EventType.CLICK_SIDEBAR_SETTING_ICON,
},
isIncognitoMode
)
}
/>
</Popover.Button>
Expand All @@ -247,9 +251,12 @@ const Sidebar = () => {
<QuestionMarkCircleIcon
className="h-5 w-5 text-slate-500"
onClick={() =>
sendEventsToServerViaWorker({
eventType: EventType.CLICK_SIDEBAR_HELP_ICON,
})
sendEventsToServerViaWorker(
{
eventType: EventType.CLICK_SIDEBAR_HELP_ICON,
},
isIncognitoMode
)
}
/>
</Popover.Button>
Expand Down
12 changes: 9 additions & 3 deletions src/shared/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { log } from "../utils/log";
import { EVENTS_HOST } from "./constants";
import { EVENTS_HOST, KEY_INCOGNITO_MODE } from "./constants";
import { useSettingsStore } from "./settings";

export enum EventType {
CLICK_SIDEBAR_FORUM_RESULT_TITLE = "click_sidebar_forum_result_title",
Expand All @@ -23,6 +24,11 @@ export const sendEventsToServer = async (payload: Map<string, any>) => {
}
};

export const sendEventsToServerViaWorker = (payload: any) => {
chrome.runtime.sendMessage({ eventPayload: payload });
export const sendEventsToServerViaWorker = (
payload: any,
isIncognitoMode: boolean
) => {
if (!isIncognitoMode) {
chrome.runtime.sendMessage({ eventPayload: payload });
}
};