Skip to content

Commit

Permalink
try removing terser
Browse files Browse the repository at this point in the history
  • Loading branch information
copelco committed Jan 15, 2024
1 parent 1a69abf commit ff360cb
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 65 deletions.
61 changes: 48 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"react-router-dom": "^5.2.0",
"react-select": "^4.3.1",
"remark-sectionize": "^1.1.1",
"styled-components": "^5.3.0",
"terser": "^5.19.4"
"styled-components": "^5.3.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.14.1",
Expand Down
95 changes: 45 additions & 50 deletions src/bookmarklet/bookmarklet.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,49 @@
const POST_URL = window.location.origin;
import { minify } from 'terser';

export const generateBookmarklet = async (username) =>
(
await minify(
`
var html = document.documentElement.innerHTML;
var loaded = 0;
var iframe = document.createElement('iframe');
iframe.name = 'bookmarklet-' + Math.floor((Math.random() * 10000) + 1);
iframe.style.display = 'none';
iframe.onload = function () {
if (++loaded == 1) {
return;
}
document.body.removeChild(iframe);
};
var form = document.createElement('form');
form.method = "POST";
form.action = '${POST_URL}/portal/bookmarklet/';
form.target = iframe.name;
var username_input = document.createElement('input');
username_input.name = 'user';
username_input.value = '${username}';
var textarea = document.createElement('textarea');
textarea.name = 'source';
textarea.value = html;
var location_input = document.createElement('input');
location_input.name = 'location';
location_input.value = window.location;
export function generateBookmarklet(username) {
return `
var html = document.documentElement.innerHTML;
var loaded = 0;
var iframe = document.createElement('iframe');
iframe.name = 'bookmarklet-' + Math.floor((Math.random() * 10000) + 1);
iframe.style.display = 'none';
iframe.onload = function () {
if (++loaded == 1) {
return;
}
document.body.removeChild(iframe);
};
var form = document.createElement('form');
form.method = "POST";
form.action = '${POST_URL}/portal/bookmarklet/';
form.target = iframe.name;
var username_input = document.createElement('input');
username_input.name = 'user';
username_input.value = '${username}';
var textarea = document.createElement('textarea');
textarea.name = 'source';
textarea.value = html;
var location_input = document.createElement('input');
location_input.name = 'location';
location_input.value = window.location;
form.appendChild(username_input);
form.appendChild(location_input);
form.appendChild(textarea);
iframe.appendChild(form);
document.body.appendChild(iframe);
form.submit();
form.appendChild(username_input);
form.appendChild(location_input);
form.appendChild(textarea);
iframe.appendChild(form);
document.body.appendChild(iframe);
form.submit();
alert("Successfully submitted case summary to Expunction Tool");
`,
{ mangle: false },
)
).code;
alert("Successfully submitted case summary to Expunction Tool");
`
}

0 comments on commit ff360cb

Please sign in to comment.