Skip to content

Commit

Permalink
Add reporting feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kewbish committed Jan 1, 2023
1 parent b45d92d commit d9d5641
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 7 deletions.
Binary file modified build.crx
Binary file not shown.
12 changes: 6 additions & 6 deletions landing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2 class="display mb-0">Cobweb</h1>
<a href="#about">about</a>
<a href="#why">why Cobweb?</a>
<a href="#how">how it works</a>
<a href="https://github.com/kewbish/cobweb/releases/tag/v0.0.1">download</a>
<a href="https://github.com/kewbish/cobweb/releases/latest">download</a>
<a href="#differences">differences</a>
<a href="https://github.com/kewbish/cobweb/wiki" target="_blank" rel="noopener noreferrer">docs</a>
</div>
Expand All @@ -26,7 +26,7 @@ <h2 class="display mb-0">Cobweb</h1>
<h1 class="display display-extra-big">Cobweb</h1>
<p class="p-20">is a <a href="https://webmonetization.org/">Web Monetization-inspired</a> tool to make supporting other teen creators and getting paid for your content easier.</p>
<div>
<a href="https://github.com/kewbish/cobweb/releases/tag/v0.0.1" class="btn glassy-cw-btn" role="button">download here</a>
<a href="https://github.com/kewbish/cobweb/releases/latest" class="btn glassy-cw-btn" role="button">download here</a>
<a href="https://github.com/kewbish/cobweb/wiki/Cobweb-Tags-&-Account-Page" target="_blank" rel="noopener noreferrer" class="btn glassy-cw-btn ms-1" role="button">...or learn how to add Cobweb to your content</a>
</div>
</div>
Expand All @@ -49,19 +49,19 @@ <h3 class="display mb-0" id="simulator-header">Cobweb</h1>
<p>Cobweb lets you stream micropayments from your browser to your favourite teen creators. For creators, this means you can add a single tag on your content to get paid. For fans, this means you can automatically support other teen creators by streaming tips in the background.</p><p>
Cobweb is affordable and user-controlled too, unlike pricy direct subscriptions. Users can choose to allow web monetization for one visit to unlock exclusive content just once. Cobweb helps shift from a passive web browsing experience to a creative, community-focused one.
</p>
<a href="https://github.com/kewbish/cobweb/releases/tag/v0.0.1" target="_blank" rel="noopener noreferrer" class="btn glassy-cw-btn mt-1" role="button">get started now</a>
<a href="https://github.com/kewbish/cobweb/releases/latest" target="_blank" rel="noopener noreferrer" class="btn glassy-cw-btn mt-1" role="button">get started now</a>
</div>
</div>
</div>
<div class="container pt-3" id="getStarted">
<h2 class="display mx-auto text-center mb-3">get started</h2>
<div class="row">
<div class="col">
<p>Cobweb is a free Chrome extension <a href="https://github.com/kewbish/cobweb/releases/tag/v0.0.1">available here</a>. FireFox and other browsers may not be fully supported. Issues and pull requests are welcome.</p>
<a href="https://github.com/kewbish/cobweb/releases/tag/v0.0.1" class="btn glassy-cw-btn mt-1" role="button">download</a>
<p>Cobweb is a free Chrome extension <a href="https://github.com/kewbish/cobweb/releases/latest">available here</a>. FireFox and other browsers may not be fully supported. Issues and pull requests are welcome.</p>
<a href="https://github.com/kewbish/cobweb/releases/latest" class="btn glassy-cw-btn mt-1" role="button">download</a>
</div>
<div class="col">
<p>Cobweb is MIT-licensed and fully open source - the source is <a href="https://github.com/kewbish/cobweb">available on GitHub</a> should you wish to build from source. The checksum of the current version is <code style="word-break:break-all;">2306e354a4b6ec976467f6dff470601aae80bfb919682c1924f99d0b1413c413</code>.
<p>Cobweb is MIT-licensed and fully open source - the source is <a href="https://github.com/kewbish/cobweb">available on GitHub</a> should you wish to build from source. The checksum of the current version is <code style="word-break:break-all;">29aec681ca1ed9d2da4f09bf558012dec69ef8f7bf81e1ccbcf8521602db7df2</code>.
</p>
<a href="https://github.com/kewbish/cobweb" class="btn glassy-cw-btn mt-1" role="button">view source</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cobweb",
"version": "0.0.1",
"version": "0.0.2",
"description": "A Web3-based Web Monetization tool enabling one-click content monetization for creative teens.",
"license": "MIT",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"manifest_version": 3,
"name": "Cobweb",
"description": "A Web3-based Web Monetization tool enabling one-click content monetization for creative teens.",
"version": "0.0.2",
"background": { "service_worker": "background.bundle.js" },
"action": {
"default_popup": "popup.html",
Expand Down
10 changes: 10 additions & 0 deletions src/pages/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ const Popup = () => {
get help
</a>
</p>
<Link to="/report">
<button
type="button"
className="btn glassy-cw-btn"
style={{ fontSize: 16, padding: "0.25rem 0.4rem", height: 27 }}
title="Report user"
>
<i className="bi bi-flag-fill"></i>
</button>
</Link>
</div>
</div>
<DropdownModal id="editingStream" title="Edit stream">
Expand Down
119 changes: 119 additions & 0 deletions src/pages/Popup/Report.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React, { useState } from "react";
import ToastHandler from "./components/ToastHandler";
import CobwebPage from "./components/CobwebPage";
import InfoPopover from "./components/InfoPopover";
import verifySignature from "../shared/verifySignature";
import { toast } from "../shared/toast";

const Report = () => {
const [oldReportingTag, setOldReportingTag] = useState("...");
const [oldReportingUrl, setOldReportingUrl] = useState("...");
const [reportingTag, setReportingTag] = useState("");
const [reportingUrl, setReportingUrl] = useState("");
const [reported, setReported] = useState(false);

const report = async () => {
const tryParseTag = verifySignature(reportingTag);
if (!tryParseTag) {
toast("Cobweb Tag is invalid.");
return;
}
if (oldReportingUrl === reportingUrl || oldReportingTag === reportingTag) {
toast("Tag already reported.");
return;
}
const response = await fetch(
"https://cobweb-worker.kewbish.workers.dev/report?" +
new URLSearchParams({
address: reportingTag,
url: reportingUrl,
}).toString()
);
const responseJson = await response.json();
if (!response.ok || !responseJson.success) {
toast("Couldn't report user, please try again.");
return;
}
setReported(true);
setOldReportingTag(reportingTag);
setOldReportingUrl(reportingUrl);
setReportingTag("");
setReportingUrl("");
};

return (
<>
<CobwebPage>
<>
<h2 className="mb-0">Report User</h2>
<hr className="my-1" />
<p style={{ fontSize: 16 }} className="mb-0">
Use this page to report spam, inappropriate Cobweb content, or other
abusive actions. Reports are manually processed and if confirmed,
will result in a ban from the Cobweb community.{" "}
</p>
<div className="d-flex flex-column align-items-start">
<label htmlFor="cobweb-report" className="mt-2">
Cobweb Tag to report (*)
</label>
<input
type="text"
className="form-control"
placeholder="Cobweb Tag to report"
aria-label="Cobweb Tag to report"
style={{
padding: "0.5rem 1rem",
}}
value={reportingTag}
onChange={(e) => {
setReportingTag(e.target.value);
setReported(false);
}}
required
id="cobweb-report"
/>
<label htmlFor="cobweb-report-url" className="mt-2 mb-1">
URL of abusive content
<InfoPopover
text="
To increase the
chances of the report being successful, please attach the URL where
the abusive content is located."
moreSquare
/>
</label>
<input
type="text"
className="form-control"
placeholder="URL to report"
aria-label="URL to report"
style={{
padding: "0.5rem 1rem",
}}
value={reportingUrl}
onChange={(e) => {
setReportingUrl(e.target.value);
setReported(false);
}}
id="cobweb-report-url"
/>
<button
onClick={report}
className="btn glassy-cw-btn p-1 mt-2"
disabled={
!verifySignature(reportingTag) ||
!reportingTag ||
reportingTag === oldReportingTag ||
reportingUrl === oldReportingUrl
}
>
{reported ? "Reported!" : "Report"}
</button>
</div>
</>
</CobwebPage>
<ToastHandler />
</>
);
};
export default Report;
2 changes: 2 additions & 0 deletions src/pages/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ListStreamsOut from "./ListStreamsOut";
import CobwebInfo from "./CobwebInfo";
import Welcome from "./Welcome";
import MetamaskNotFound from "./MetamaskNotFound";
import Report from "./Report";

render(
<Router>
Expand All @@ -31,6 +32,7 @@ render(
<Route path="streams/out" element={<ListStreamsOut />} />
<Route path="welcome" element={<Welcome />} />
<Route path="metamask/not-found" element={<MetamaskNotFound />} />
<Route path="report" element={<Report />} />
</Routes>
</Router>,
window.document.querySelector("#app-container")
Expand Down
38 changes: 38 additions & 0 deletions worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,42 @@ const worker = {
}
};

const reportUser = async (): Promise<Response> => {
const params = new URLSearchParams(new URL(request.url).search);
const address = params.get("address");
const url = params.get("url");
if (address) {
if (env.ENVIRONMENT === "dev") {
logger(
"Report received for: " + address + (url ? " with URL " + url : ""),
"REPT"
);
}
fetch(env.WEBHOOK_URL, {
method: "POST",
body: JSON.stringify({
content: null,
embeds: [
{
title: "New Cobweb User Report",
description:
`Tag: \`${address}\`` + (url ? `\nURL: ${url}` : ""),
color: 14367074,
},
],
attachments: [],
}),
headers: { "Content-Type": "application/json" },
});
return new Response(JSON.stringify({ success: true }), HEADERS);
} else {
return new Response(JSON.stringify({ error: "No tag provided." }), {
...HEADERS,
status: 400,
});
}
};

const requestNewUser = async (): Promise<Response> => {
const params = new URLSearchParams(new URL(request.url).search);
const address = params.get("address");
Expand Down Expand Up @@ -224,6 +260,8 @@ const worker = {
return addNewUser();
} else if (url.pathname === "/request") {
return requestNewUser();
} else if (url.pathname === "/report") {
return reportUser();
} else {
return returnUserInformation();
}
Expand Down

0 comments on commit d9d5641

Please sign in to comment.