Skip to content

Commit 870c202

Browse files
committed
issue #71 - better input validation
1 parent c7ee802 commit 870c202

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

manifest.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "DocDecoder - AI-Powered Policy Summariser",
44
"description": "DocDecoder uses GPT-4 to generate clear, concise summaries of any site's legal policies for you to skim over before you accept them.",
5-
"version": "1.1.2",
5+
"version": "1.1.3",
66
"action": {
77
"default_popup": "popup.html",
88
"default_icon": {
@@ -11,6 +11,11 @@
1111
"128": "docdecoderlogo.png"
1212
}
1313
},
14+
"icons": {
15+
"16": "docdecoderlogo.png",
16+
"48": "docdecoderlogo.png",
17+
"128": "docdecoderlogo.png"
18+
},
1419
"background": {
1520
"service_worker": "background.js"
1621
},

popup.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ <h4 id="summaries-container-placeholder" class="text-base font-mono font-semibol
7676
<div id="premiumFeatureMessage" style="display: none;" class="mb-4 p-4 border-l-4 border-red-500 bg-red-100">
7777
<p class="mb-0">This is a premium feature. Please <a href="#" id="premium-subscribe-txt" class="underline">subscribe</a> to access it.</p>
7878
</div>
79-
<p class="-mb-4 text-center text-gray-300">Created by <a href="https://www.instagram.com/joshwallerr/" target="_blank">Josh Waller</a> | josh@docdecoder.app</p>
79+
<p class="-mb-4 text-center text-gray-300">Created by <a href="https://www.instagram.com/joshwallerr/" target="_blank">Josh Waller</a> | support@docdecoder.app</p>
8080
</section>
8181

8282
<div id="gensum-container" style="display: none;" tabindex="-1" class="flex justify-center fixed top-0 left-0 right-0 z-50 w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0 !h-[calc(100%-1rem)] max-h-full">
@@ -102,7 +102,7 @@ <h3 class="text-xl font-medium text-gray-900 mb-0">
102102
<p>If we haven't summarised a policy yet, you can create your own summary using the form below.</p>
103103
<p class="font-semibold">Each summary you generate costs 1 summary token.</p>
104104
<input type="url" name="policyLink" id="policyLink" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 mx-auto rounded-t-2xl" placeholder="Link to policy (e.g. https://example.com/terms)" required="">
105-
<input type="text" id="policyName" class="bg-gray-50 border border-t-0 border-gray-300 text-gray-900 sm:text-sm focus:ring-primary-600 focus:border-primary-600 w-full p-2.5 mx-auto rounded-b-2xl" placeholder="Policy name (e.g. Terms and Conditions)" required="" pattern="[A-Za-z&' ]*">
105+
<input type="text" id="policyName" class="bg-gray-50 border border-t-0 border-gray-300 text-gray-900 sm:text-sm focus:ring-primary-600 focus:border-primary-600 w-full p-2.5 mx-auto rounded-b-2xl" placeholder="Policy name (e.g. Terms and Conditions)" required="" pattern="^[^.$]*$">
106106
</div>
107107
<div id="suggested-links" class="text-xs">
108108
<p class="font-semibold text-sm mb-1">Suggested links:</p>

popup.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,20 +412,23 @@ document.addEventListener('DOMContentLoaded', function () {
412412
document.getElementById("notifs-toggle").addEventListener("change", function(e) {
413413
chrome.storage.local.set({ notificationsEnabled: e.target.checked });
414414
});
415-
416-
document.getElementById('policyName').addEventListener('input', function (e) {
417-
if (!e.target.validity.valid) {
418-
e.target.setCustomValidity("Policy names can only contain letters, apostrophes ('), numbers, spaces and ampersand symbols (&).");
419-
} else {
420-
e.target.setCustomValidity("");
421-
}
415+
416+
var policyInput = document.getElementById('policyName');
417+
418+
policyInput.addEventListener('invalid', function(event) {
419+
// Prevent the default browser tooltip
420+
event.preventDefault();
421+
// Set custom validation message
422+
this.setCustomValidity("Policy names cannot contain periods (.) or dollar signs ($).");
423+
// Report the validity state with the custom error message
424+
this.reportValidity();
422425
});
423426

424-
document.getElementById('policyName').addEventListener('invalid', function (e) {
425-
if (!e.target.validity.valid) {
426-
e.target.setCustomValidity("Policy names can only contain letters, apostrophes ('), numbers, spaces and ampersand symbols (&).");
427-
}
427+
// Reset the custom validity message after the user starts modifying the input
428+
policyInput.addEventListener('input', function() {
429+
this.setCustomValidity('');
428430
});
431+
429432

430433
const isFormOpen = localStorage.getItem('isFormOpen') === 'true';
431434
const formOpenTimestamp = parseInt(localStorage.getItem('formOpenTimestamp') || '0');
@@ -613,11 +616,6 @@ function logUserOut() {
613616
});
614617
}
615618

616-
617-
618-
619-
620-
621619
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
622620
chrome.storage.local.get(['domainSummaryCounts'], function(data) {
623621
const currentTab = tabs[0];

0 commit comments

Comments
 (0)