From 8d925d68c4d812cc120346871226c5259c72aa5f Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Tue, 19 Nov 2024 19:46:22 -0800 Subject: [PATCH] =?UTF-8?q?ui:=20add=20a=20'Preferences'=20tab=20to=20the?= =?UTF-8?q?=20Settings=20tab=20that=20allows=20enabling=20=E2=80=A6=20(#27?= =?UTF-8?q?6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …saving of cookies and localStorage (actual support for this in separate PR) - Updates Browsertrix link and description --------- Co-authored-by: Henry Wilkinson --- src/ui/app.ts | 90 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 7 deletions(-) diff --git a/src/ui/app.ts b/src/ui/app.ts index 3804f12f..de9fdde1 100644 --- a/src/ui/app.ts +++ b/src/ui/app.ts @@ -65,7 +65,7 @@ class ArchiveWebApp extends ReplayWebApp { this.settingsError = ""; - this.settingsTab = localStorage.getItem("settingsTab") || "browsertrix"; + this.settingsTab = localStorage.getItem("settingsTab") || "prefs"; try { const res = localStorage.getItem("ipfsOpts"); @@ -91,6 +91,10 @@ class ArchiveWebApp extends ReplayWebApp { this.btrixOpts = null; } + if (!self.localStorage.getItem("archiveCookies")) { + self.localStorage.setItem("archiveCookies", "1"); + } + getLocalOption("autorunBehaviors").then( (res) => (this.autorun = res === "1"), ); @@ -987,10 +991,21 @@ class ArchiveWebApp extends ReplayWebApp { } renderSettingsModal() { + let archiveCookies = false, + archiveStorage = false; + if (this.settingsTab === "prefs") { + archiveCookies = self.localStorage.getItem("archiveCookies") === "1"; + archiveStorage = self.localStorage.getItem("archiveStorage") === "1"; + } return html`
    +
  • + (this.settingsTab = "prefs")} + >Archiving Privacy +
  • @@ -1008,6 +1023,51 @@ class ArchiveWebApp extends ReplayWebApp { class="is-flex is-flex-direction-column is-size-7" @submit="${this.onSaveSettings}" > + ${this.settingsTab === "prefs" + ? html`
    +
    + Control archiving of sensitive browser data. +
    +
    + Archive cookies +

    + Archiving cookies may expose private information that is + normally only shared with the site. When enabled, + users should exercise caution about sharing these archived + items publicly. +

    +
    +
    + Archive local storage +

    + Archiving local storage will archive information that is + generally always private. Archiving local storage + may be required for certain paywalled sites but should be + avoided where possible. +

    +

    + Sharing content created with this setting enabled may + compromise your login credentials. +
    Archived items created with this settings should + generally be kept private! +

    +
    +
    ` + : ``} ${this.settingsTab === "ipfs" ? html`

    Configure settings for sharing archived items to IPFS. @@ -1054,14 +1114,13 @@ class ArchiveWebApp extends ReplayWebApp { ? html`

    Configure your credentials to upload archived items to - Browsertrix. + Browsertrix: Webrecorder's cloud-based crawling service.

    - Don't have a Browsertrix account? Visit - https://browsertrix.com/Sign up today! - for more info.

    @@ -1276,7 +1335,7 @@ class ArchiveWebApp extends ReplayWebApp { } // @ts-expect-error - TS7006 - Parameter 'event' implicitly has an 'any' type. - async onTitle(event) { + override async onTitle(event): void { super.onTitle(event); if ( @@ -1363,6 +1422,23 @@ class ArchiveWebApp extends ReplayWebApp { } } + const archiveCookies = this.renderRoot.querySelector("#archiveCookies"); + const archiveStorage = this.renderRoot.querySelector("#archiveStorage"); + + if (archiveCookies) { + self.localStorage.setItem( + "archiveCookies", + (archiveCookies as HTMLInputElement).checked ? "1" : "0", + ); + } + + if (archiveStorage) { + self.localStorage.setItem( + "archiveStorage", + (archiveStorage as HTMLInputElement).checked ? "1" : "0", + ); + } + localStorage.setItem("settingsTab", this.settingsTab); // @ts-expect-error - TS2339 - Property 'showSettings' does not exist on type 'ArchiveWebApp'.