import { LitElement, html, css, unsafeCSS } from "lit"; import { customElement } from "lit/decorators.js"; import { unsafeSVG } from "lit/directives/unsafe-svg.js"; import bulma from "bulma/bulma.sass"; import fasPlus from "@fortawesome/fontawesome-free/svgs/solid/plus.svg"; import fasBox from "@fortawesome/fontawesome-free/svgs/solid/square.svg"; import fasPlay from "@fortawesome/fontawesome-free/svgs/solid/play.svg"; import fasPause from "@fortawesome/fontawesome-free/svgs/solid/pause.svg"; import fasHome from "@fortawesome/fontawesome-free/svgs/solid/home.svg"; import fasQ from "@fortawesome/fontawesome-free/svgs/solid/question.svg"; import fasCheck from "@fortawesome/fontawesome-free/svgs/solid/check.svg"; import fasX from "@fortawesome/fontawesome-free/svgs/solid/times.svg"; import fasCaretDown from "@fortawesome/fontawesome-free/svgs/solid/caret-down.svg"; import wrRec from "./assets/icons/recLogo.svg"; import prettyBytes from "pretty-bytes"; import { getLocalOption, removeLocalOption, setLocalOption, } from "./localstorage"; import { BEHAVIOR_WAIT_LOAD, BEHAVIOR_READY_START, BEHAVIOR_RUNNING, BEHAVIOR_PAUSED, BEHAVIOR_DONE, } from "./consts"; const allCss = unsafeCSS(bulma); // @ts-expect-error - TS7006 - Parameter 'custom' implicitly has an 'any' type. function wrapCss(custom) { return [allCss, custom]; } // =========================================================================== @customElement("wr-popup-viewer") class RecPopup extends LitElement { constructor() { super(); // @ts-expect-error - TS2339 - Property 'collections' does not exist on type 'RecPopup'. this.collections = []; // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. this.collTitle = ""; // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. this.collId = ""; // @ts-expect-error - TS2339 - Property 'tabId' does not exist on type 'RecPopup'. this.tabId = 0; // @ts-expect-error - TS2339 - Property 'recording' does not exist on type 'RecPopup'. this.recording = false; // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. this.status = null; // @ts-expect-error - TS2339 - Property 'port' does not exist on type 'RecPopup'. this.port = null; // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. this.pageUrl = ""; // @ts-expect-error - TS2339 - Property 'pageTs' does not exist on type 'RecPopup'. this.pageTs = 0; // @ts-expect-error - TS2339 - Property 'replayUrl' does not exist on type 'RecPopup'. this.replayUrl = ""; // @ts-expect-error - TS2339 - Property 'canRecord' does not exist on type 'RecPopup'. this.canRecord = false; // @ts-expect-error - TS2339 - Property 'failureMsg' does not exist on type 'RecPopup'. this.failureMsg = null; // @ts-expect-error - TS2339 - Property 'collDrop' does not exist on type 'RecPopup'. this.collDrop = ""; // @ts-expect-error - TS2339 - Property 'allowCreate' does not exist on type 'RecPopup'. this.allowCreate = true; // @ts-expect-error - TS2339 - Property 'waitingForStart' does not exist on type 'RecPopup'. this.waitingForStart = false; // @ts-expect-error - TS2339 - Property 'waitingForStop' does not exist on type 'RecPopup'. this.waitingForStop = false; // @ts-expect-error - TS2339 - Property 'behaviorState' does not exist on type 'RecPopup'. this.behaviorState = BEHAVIOR_WAIT_LOAD; // @ts-expect-error - TS2339 - Property 'behaviorMsg' does not exist on type 'RecPopup'. this.behaviorMsg = ""; // @ts-expect-error - TS2339 - Property 'autorun' does not exist on type 'RecPopup'. this.autorun = false; } static get properties() { return { collections: { type: Array }, collId: { type: String }, collTitle: { type: String }, collDrop: { type: String }, recording: { type: Boolean }, status: { type: Object }, waitingForStart: { type: Boolean }, replayUrl: { type: String }, pageUrl: { type: String }, pageTs: { type: Number }, canRecord: { type: Boolean }, failureMsg: { type: String }, behaviorState: { type: String }, behaviorResults: { type: Object }, behaviorMsg: { type: String }, autorun: { type: Boolean }, }; } async firstUpdated() { document.addEventListener("click", () => { // @ts-expect-error - TS2339 - Property 'collDrop' does not exist on type 'RecPopup'. if (this.collDrop === "show") { // @ts-expect-error - TS2339 - Property 'collDrop' does not exist on type 'RecPopup'. this.collDrop = ""; } }); // @ts-expect-error - TS2339 - Property 'autorun' does not exist on type 'RecPopup'. this.autorun = (await getLocalOption("autorunBehaviors")) === "1"; this.registerMessages(); } registerMessages() { // @ts-expect-error - TS2339 - Property 'port' does not exist on type 'RecPopup'. this.port = chrome.runtime.connect({ name: "popup-port" }); // @ts-expect-error - TS7006 - Parameter 'tabs' implicitly has an 'any' type. chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { if (tabs.length) { // @ts-expect-error - TS2339 - Property 'tabId' does not exist on type 'RecPopup'. this.tabId = tabs[0].id; // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. this.pageUrl = tabs[0].url; // @ts-expect-error - TS2339 - Property 'tabId' does not exist on type 'RecPopup'. | TS7006 - Parameter 'result' implicitly has an 'any' type. chrome.action.getTitle({ tabId: this.tabId }, (result) => { // @ts-expect-error - TS2339 - Property 'recording' does not exist on type 'RecPopup'. this.recording = result.indexOf("Recording:") >= 0; }); // @ts-expect-error - TS2339 - Property 'tabId' does not exist on type 'RecPopup'. this.sendMessage({ tabId: this.tabId, type: "startUpdates" }); } }); // @ts-expect-error - TS2339 - Property 'port' does not exist on type 'RecPopup'. this.port.onMessage.addListener((message) => { this.onMessage(message); }); } // @ts-expect-error - TS7006 - Parameter 'message' implicitly has an 'any' type. sendMessage(message) { // @ts-expect-error - TS2339 - Property 'port' does not exist on type 'RecPopup'. this.port.postMessage(message); } // @ts-expect-error - TS7006 - Parameter 'message' implicitly has an 'any' type. async onMessage(message) { switch (message.type) { case "status": // @ts-expect-error - TS2339 - Property 'recording' does not exist on type 'RecPopup'. this.recording = message.recording; // @ts-expect-error - TS2339 - Property 'waitingForStart' does not exist on type 'RecPopup'. if (this.waitingForStart && message.firstPageStarted) { // @ts-expect-error - TS2339 - Property 'waitingForStart' does not exist on type 'RecPopup'. this.waitingForStart = false; } // @ts-expect-error - TS2339 - Property 'waitingForStop' does not exist on type 'RecPopup'. if (this.waitingForStop && !message.recording && !message.stopping) { // @ts-expect-error - TS2339 - Property 'waitingForStop' does not exist on type 'RecPopup'. this.waitingForStop = false; } // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. this.status = message; // @ts-expect-error - TS2339 - Property 'behaviorState' does not exist on type 'RecPopup'. this.behaviorState = message.behaviorState; // @ts-expect-error - TS2339 - Property 'behaviorMsg' does not exist on type 'RecPopup'. this.behaviorMsg = message.behaviorData?.msg || "Starting..."; // @ts-expect-error - TS2339 - Property 'behaviorResults' does not exist on type 'RecPopup'. this.behaviorResults = message.behaviorData?.state; // @ts-expect-error - TS2339 - Property 'autorun' does not exist on type 'RecPopup'. this.autorun = message.autorun; if (message.pageUrl) { // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. this.pageUrl = message.pageUrl; } if (message.pageTs) { // @ts-expect-error - TS2339 - Property 'pageTs' does not exist on type 'RecPopup'. this.pageTs = message.pageTs; } // @ts-expect-error - TS2339 - Property 'failureMsg' does not exist on type 'RecPopup'. this.failureMsg = message.failureMsg; // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. if (this.collId !== message.collId) { // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. this.collId = message.collId; // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. | TS2339 - Property 'collId' does not exist on type 'RecPopup'. this.collTitle = this.findTitleFor(this.collId); // @ts-expect-error - TS2339 - Property 'tabId' does not exist on type 'RecPopup'. | TS2339 - Property 'collId' does not exist on type 'RecPopup'. await setLocalOption(`${this.tabId}-collId`, this.collId); } break; case "collections": // @ts-expect-error - TS2339 - Property 'collections' does not exist on type 'RecPopup'. this.collections = message.collections; // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. | TS2339 - Property 'tabId' does not exist on type 'RecPopup'. this.collId = await getLocalOption(`${this.tabId}-collId`); // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. this.collTitle = ""; // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. if (this.collId) { // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. | TS2339 - Property 'collId' does not exist on type 'RecPopup'. this.collTitle = this.findTitleFor(this.collId); } // may no longer be valid, try default id // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. if (!this.collTitle) { // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. this.collId = message.collId; // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. | TS2339 - Property 'collId' does not exist on type 'RecPopup'. this.collTitle = this.findTitleFor(this.collId); } // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. if (!this.collTitle) { // @ts-expect-error - TS2339 - Property 'collTitle' does not exist on type 'RecPopup'. this.collTitle = "[No Title]"; } break; } } // @ts-expect-error - TS7006 - Parameter 'match' implicitly has an 'any' type. findTitleFor(match) { if (!match) { return ""; } // @ts-expect-error - TS2339 - Property 'collections' does not exist on type 'RecPopup'. for (const coll of this.collections) { // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. if (coll.id === this.collId) { return coll.title; } } return ""; } // @ts-expect-error - TS7006 - Parameter 'changedProperties' implicitly has an 'any' type. updated(changedProperties) { if ( // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. this.pageUrl && // @ts-expect-error - TS2339 - Property 'pageTs' does not exist on type 'RecPopup'. this.pageTs && (changedProperties.has("pageUrl") || changedProperties.has("pageTs") || changedProperties.has("recording") || changedProperties.has("collId")) ) { const params = new URLSearchParams(); // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. params.set("url", this.pageUrl); params.set( "ts", // @ts-expect-error - TS2339 - Property 'pageTs' does not exist on type 'RecPopup'. new Date(this.pageTs).toISOString().replace(/[-:TZ.]/g, ""), ); params.set("view", "pages"); // @ts-expect-error - TS2339 - Property 'replayUrl' does not exist on type 'RecPopup'. this.replayUrl = this.getCollPage() + "#" + params.toString(); } if ( changedProperties.has("pageUrl") || changedProperties.has("failureMsg") ) { // @ts-expect-error - TS2339 - Property 'canRecord' does not exist on type 'RecPopup'. this.canRecord = // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. this.pageUrl && // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. (this.pageUrl === "about:blank" || // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. this.pageUrl.startsWith("http:") || // @ts-expect-error - TS2339 - Property 'pageUrl' does not exist on type 'RecPopup'. this.pageUrl.startsWith("https:")); } } getHomePage() { return chrome.runtime.getURL("index.html"); } get extRoot() { return chrome.runtime.getURL(""); } getCollPage() { const sourceParams = new URLSearchParams(); // @ts-expect-error - TS2339 - Property 'collId' does not exist on type 'RecPopup'. sourceParams.set("source", "local://" + this.collId); return this.getHomePage() + "?" + sourceParams.toString(); } get notRecordingMessage() { return "Not Archiving this Tab"; } static get styles() { return wrapCss(css` :host { width: 100%; height: 100%; font-size: initial !important; } .button { height: 1.5em !important; background-color: aliceblue; } .smallest.button { margin: 0.25em; background-color: initial; padding: 6px 12px; } .rec-state { margin-right: 1em; flex: auto; } .status-row { display: flex; flex-direction: row; align-items: center; padding-bottom: 0.5em; border-bottom: 1px solid lightgrey; } .view-row { display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-top: 0.5em; font-size: 1.1em; } .autopilot { justify-content: center; } .coll-select { align-items: center; } .dropdown-item { width: initial !important; } .coll.button { max-width: 120px; } .coll.button span { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } .flex-form { display: flex; flex-direction: row; align-items: center; width: 100%; } .flex-form * { padding: 0.5em; } .session-head { font-style: italic; } .underline { margin-top: 1em; border-bottom: 1px gray solid; margin-bottom: 0.5em; } .status th { padding-left: 0.5em; } .status { font-variant-caps: all-small-caps; } .status-sep { border-bottom: 1px solid black; width: 100%; height: 10px; } .status-ready { color: #459558; font-style: italic; } .status-autopilot { color: #3298dc; max-width: 330px; text-overflow: wrap; word-break: break-all; } .status-pending { color: #bb9f08; font-style: italic; } .error { font-size: 12px; color: maroon; } .error p { margin-bottom: 1em; } .error-msg { font-family: monospace; font-style: italic; } `); } renderStatus() { // @ts-expect-error - TS2339 - Property 'behaviorState' does not exist on type 'RecPopup'. if (this.behaviorState === BEHAVIOR_RUNNING) { return html`Auto Recording, ${ // @ts-expect-error - TS2339 - Property 'behaviorMsg' does not exist on type 'RecPopup'. this.behaviorMsg }`; } // @ts-expect-error - TS2339 - Property 'recording' does not exist on type 'RecPopup'. if (this.recording) { return html`${ // @ts-expect-error - TS2339 - Property 'waitingForStop' does not exist on type 'RecPopup'. this.waitingForStop ? "Finishing " : "" } Archiving: ${ // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. | TS2339 - Property 'status' does not exist on type 'RecPopup'. this.status?.numPending ? html` ${ // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. this.status.numPending } URLs pending${ // @ts-expect-error - TS2339 - Property 'waitingForStop' does not exist on type 'RecPopup'. this.waitingForStop ? "." : ", please wait before loading a new page." } ` : html` Idle, Continue Browsing` }`; } // @ts-expect-error - TS2339 - Property 'failureMsg' does not exist on type 'RecPopup'. if (this.failureMsg) { return html`
Sorry, there was an error starting archiving on this page. Please try again or try a different page.
Error Details: ${ // @ts-expect-error - TS2339 - Property 'failureMsg' does not exist on type 'RecPopup'. this.failureMsg }
If the error persists, check the Common Errors and Issues page in the guide for known issues and possible solutions.
This page is part of the extension. You can view existing archived
items from here. To start a new archiving session, click the
| Size Stored: | ${ // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. prettyBytes(this.status.sizeNew) } |
|---|---|
| Size Loaded: | ${ // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. prettyBytes(this.status.sizeTotal) } |
| Pages: | ${ // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. this.status.numPages } |
| URLs: | ${ // @ts-expect-error - TS2339 - Property 'status' does not exist on type 'RecPopup'. this.status.numUrls } |
| ${name} | ${value} |