Skip to content

Commit 8d925d6

Browse files
ikreymerShrinks99
andauthored
ui: add a 'Preferences' tab to the Settings tab that allows enabling … (#276)
…saving of cookies and localStorage (actual support for this in separate PR) - Updates Browsertrix link and description --------- Co-authored-by: Henry Wilkinson <henry@wilkinson.graphics>
1 parent 27c684a commit 8d925d6

File tree

1 file changed

+83
-7
lines changed

1 file changed

+83
-7
lines changed

src/ui/app.ts

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ArchiveWebApp extends ReplayWebApp {
6565

6666
this.settingsError = "";
6767

68-
this.settingsTab = localStorage.getItem("settingsTab") || "browsertrix";
68+
this.settingsTab = localStorage.getItem("settingsTab") || "prefs";
6969

7070
try {
7171
const res = localStorage.getItem("ipfsOpts");
@@ -91,6 +91,10 @@ class ArchiveWebApp extends ReplayWebApp {
9191
this.btrixOpts = null;
9292
}
9393

94+
if (!self.localStorage.getItem("archiveCookies")) {
95+
self.localStorage.setItem("archiveCookies", "1");
96+
}
97+
9498
getLocalOption("autorunBehaviors").then(
9599
(res) => (this.autorun = res === "1"),
96100
);
@@ -987,10 +991,21 @@ class ArchiveWebApp extends ReplayWebApp {
987991
}
988992

989993
renderSettingsModal() {
994+
let archiveCookies = false,
995+
archiveStorage = false;
996+
if (this.settingsTab === "prefs") {
997+
archiveCookies = self.localStorage.getItem("archiveCookies") === "1";
998+
archiveStorage = self.localStorage.getItem("archiveStorage") === "1";
999+
}
9901000
return html`
9911001
<wr-modal @modal-closed="${this.onCancelSettings}" title="Settings">
9921002
<div class="tabs mb-3">
9931003
<ul>
1004+
<li class="${this.settingsTab === "prefs" ? "is-active" : ""}">
1005+
<a @click=${() => (this.settingsTab = "prefs")}
1006+
>Archiving Privacy</a
1007+
>
1008+
</li>
9941009
<li
9951010
class="${this.settingsTab === "browsertrix" ? "is-active" : ""}"
9961011
>
@@ -1008,6 +1023,51 @@ class ArchiveWebApp extends ReplayWebApp {
10081023
class="is-flex is-flex-direction-column is-size-7"
10091024
@submit="${this.onSaveSettings}"
10101025
>
1026+
${this.settingsTab === "prefs"
1027+
? html` <fieldset>
1028+
<div class="is-size-6">
1029+
Control archiving of sensitive browser data.
1030+
</div>
1031+
<div class="field is-size-6 mt-4">
1032+
<input
1033+
name="prefArchiveCookies"
1034+
id="archiveCookies"
1035+
class="checkbox"
1036+
type="checkbox"
1037+
?checked="${archiveCookies}"
1038+
/><span class="ml-1">Archive cookies</span>
1039+
<p class="is-size-7 mt-1">
1040+
Archiving cookies may expose private information that is
1041+
<em>normally only shared with the site</em>. When enabled,
1042+
users should exercise caution about sharing these archived
1043+
items publicly.
1044+
</p>
1045+
</div>
1046+
<div class="field is-size-6 mt-4">
1047+
<input
1048+
name="prefArchiveStorage"
1049+
id="archiveStorage"
1050+
class="checkbox"
1051+
type="checkbox"
1052+
?checked="${archiveStorage}"
1053+
/><span class="ml-1">Archive local storage</span>
1054+
<p class="is-size-7 mt-1">
1055+
Archiving local storage will archive information that is
1056+
generally <em>always private.</em> Archiving local storage
1057+
may be required for certain paywalled sites but should be
1058+
avoided where possible.
1059+
</p>
1060+
<p class="is-size-7 mt-1">
1061+
<strong
1062+
>Sharing content created with this setting enabled may
1063+
compromise your login credentials.</strong
1064+
>
1065+
<br />Archived items created with this settings should
1066+
generally be kept private!
1067+
</p>
1068+
</div>
1069+
</fieldset>`
1070+
: ``}
10111071
${this.settingsTab === "ipfs"
10121072
? html` <p class="is-size-6 mb-3">
10131073
Configure settings for sharing archived items to IPFS.
@@ -1054,14 +1114,13 @@ class ArchiveWebApp extends ReplayWebApp {
10541114
? html`
10551115
<p class="is-size-6 mb-3">
10561116
Configure your credentials to upload archived items to
1057-
Browsertrix.
1117+
Browsertrix: Webrecorder's cloud-based crawling service.
10581118
</p>
10591119
<p class="is-size-7 p-4 has-background-info">
1060-
Don't have a Browsertrix account? Visit
1061-
<a target="_blank" href="https://browsertrix.com/"
1062-
>https://browsertrix.com/</a
1120+
Don't have a Browsertrix account?
1121+
<a target="_blank" href="https://webrecorder.net/browsertrix/"
1122+
>Sign up today!</a
10631123
>
1064-
for more info.
10651124
</p>
10661125
<fieldset>
10671126
<div class="field has-addons">
@@ -1276,7 +1335,7 @@ class ArchiveWebApp extends ReplayWebApp {
12761335
}
12771336

12781337
// @ts-expect-error - TS7006 - Parameter 'event' implicitly has an 'any' type.
1279-
async onTitle(event) {
1338+
override async onTitle(event): void {
12801339
super.onTitle(event);
12811340

12821341
if (
@@ -1363,6 +1422,23 @@ class ArchiveWebApp extends ReplayWebApp {
13631422
}
13641423
}
13651424

1425+
const archiveCookies = this.renderRoot.querySelector("#archiveCookies");
1426+
const archiveStorage = this.renderRoot.querySelector("#archiveStorage");
1427+
1428+
if (archiveCookies) {
1429+
self.localStorage.setItem(
1430+
"archiveCookies",
1431+
(archiveCookies as HTMLInputElement).checked ? "1" : "0",
1432+
);
1433+
}
1434+
1435+
if (archiveStorage) {
1436+
self.localStorage.setItem(
1437+
"archiveStorage",
1438+
(archiveStorage as HTMLInputElement).checked ? "1" : "0",
1439+
);
1440+
}
1441+
13661442
localStorage.setItem("settingsTab", this.settingsTab);
13671443

13681444
// @ts-expect-error - TS2339 - Property 'showSettings' does not exist on type 'ArchiveWebApp'.

0 commit comments

Comments
 (0)