199 |
200 |
201 |
204 |
210 |
214 |
218 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
--------------------------------------------------------------------------------
/chrome_extension/src/popup.js:
--------------------------------------------------------------------------------
1 | document.getElementById("xTimelineButton").addEventListener("click", () => {
2 | const openInNewWindow = document.getElementById("newWindowCheckbox").checked;
3 | const demoData = document.getElementById("demoDataCheckbox").checked;
4 | // Get the state of the custom URL checkbox and input
5 | const useCustomUrl = document.getElementById("customUrlCheckbox").checked;
6 | const customUrlInput = document.getElementById("customUrlInput").value;
7 | // Determine the URL to use
8 | const targetUrl = useCustomUrl && customUrlInput ? customUrlInput : "http://localhost:3000";
9 | chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
10 | chrome.tabs.sendMessage(tabs[0].id, {
11 | action: "parseXTimeline",
12 | openInNewWindow,
13 | demoData,
14 | url: targetUrl, // Add the URL to the message
15 | });
16 | });
17 | });
18 |
19 | // Code to toggle the visibility of the custom URL input field based on the checkbox state
20 | document.getElementById("customUrlCheckbox").addEventListener("change", function() {
21 | if(this.checked) {
22 | document.getElementById("customUrlInput").style.display = "block";
23 | } else {
24 | document.getElementById("customUrlInput").style.display = "none";
25 | }
26 | });
27 |
28 | // const listenerTwitter = () => {
29 | // chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
30 | // chrome.scripting.executeScript({target: {tabId: tabs[0].id}, function: filterTwitterTimeline});
31 | // });
32 | // };
33 |
34 | // const listenerNotImplemented = () => {
35 | // chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
36 | // chrome.scripting.executeScript({
37 | // target: { tabId: tabs[0].id },
38 | // function: () => alert("Not implemented yet"),
39 | // });
40 | // });
41 | // };
42 | // document
43 | // .getElementById("fbFilterButton")
44 | // .addEventListener("click", listenerNotImplemented);
45 | // document
46 | // .getElementById("moreFilterButton")
47 | // .addEventListener("click", listenerNotImplemented);
48 |
--------------------------------------------------------------------------------
/components.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://ui.shadcn.com/schema.json",
3 | "style": "default",
4 | "rsc": true,
5 | "tsx": true,
6 | "tailwind": {
7 | "config": "tailwind.config.ts",
8 | "css": "app/globals.css",
9 | "baseColor": "slate",
10 | "cssVariables": true,
11 | "prefix": ""
12 | },
13 | "aliases": {
14 | "components": "@/components",
15 | "utils": "@/lib/utils"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/components/classifier.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { z } from "zod";
3 | import OpenAI from "openai";
4 |
5 | import { runOpenAICompletion } from "@/lib/utils";
6 | import { getStockData, getPoliticalLeaning } from "@/lib/test-data";
7 |
8 | import {
9 | getWeatherApi,
10 | getPoliticalApi,
11 | getStockApi,
12 | getClothingApi,
13 | } from "@/lib/data";
14 |
15 | import { Weather } from "@/components/dui/weather";
16 | import { Stocks } from "@/components/dui/stocks";
17 | import { Politics } from "@/components/dui/politics";
18 | import { Clothing } from "./dui/clothing";
19 |
20 | import type { Tweet } from "@/types/tweets";
21 |
22 | const openai = new OpenAI({
23 | apiKey:
24 | process.env.OPENAI_API_KEY || process.env.NEXT_PUBLIC_OPENAI_API_KEY || "",
25 | dangerouslyAllowBrowser: true,
26 | });
27 |
28 | function classifyTweetByContent(
29 | tweet: Tweet,
30 | onUpdateDynamic: (component: React.ReactNode, isDone: boolean) => void,
31 | onReplyToText: (newText: string) => void,
32 | onReplaceTweetText: (newText: string) => void,
33 | ) {
34 | const tweetContent = tweet.content;
35 |
36 | // Hardcode Clothing UI for now
37 | // TODO: @Dhruv
38 | if (tweet.user.username === "@TechBroDrip") {
39 | if (tweet.media && tweet.media.length && tweet.media[0].url) {
40 | getClothingApi(tweet.media[0].url)
41 | .then((clothingData) => {
42 | onUpdateDynamic(