Skip to content

Commit

Permalink
Show exported info in a textarea instead of a new window
Browse files Browse the repository at this point in the history
  • Loading branch information
gyng committed May 6, 2018
1 parent 7230aad commit 77fa289
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 74 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 2.6.1
# 2.6.2

* Fix import settings on options page being totally broken
* Remove debug information and last download information from options

# 2.6.0

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "2.6.1",
"version": "2.6.2",
"default_locale": "en",

"applications": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "save-in",
"version": "2.6.1",
"version": "2.6.2",
"license": "MIT",
"scripts": {
"build": "env -u WEB_EXT_API_KEY -u WEB_EXT_API_SECRET web-ext build --overwrite-dest -i test docs yarn.lock yarn-error.log",
Expand Down
7 changes: 2 additions & 5 deletions src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ <h3>Behavior</h3>
<label>
<input type="checkbox" id="tabEnabled" class="chrome-disabled" /> Enable saving from tabstrip
<span class="badge">Firefox</span>
<span class="warning badge">Experimental</span>
<div class="caption caption-line">Saves a tab, tab group, or tabs to right</div>
</label>

Expand Down Expand Up @@ -429,18 +428,16 @@ <h2 id="section-more-options">More Options
<input type="checkbox" id="fetchViaContent" class="chrome-disabled" />
<span>Enable fetching via content script</span>
<span class="badge">Firefox</span>
<span class="warning badge">Experimental</span>
<div class="caption caption-line">Slower and prone to failure. Send headers from page with download request. Success/failure notifications do not work
<div class="caption caption-line">Send headers from page with download request. Some sites such as pixiv require this. Slower and prone to failure. Success/failure notifications do not work
in this mode. Requires page refresh to take effect.</div>
</label>

<div style="display: flex; justify-content: flex-start; align-items: center;">
<div id="settings-import" class="button">Import Settings</div>
<div style="margin-left: 8px;" id="settings-export" class="button">Export Settings</div>
<div style="margin-left: 8px;" id="print-debug-info" class="button">Show Debug Information</div>
</div>

<div id="show-last-download" class="button" style="align-self: flex-start">Last Download Info</div>
<textarea id="export-target" style="display: none;" spellcheck="false"></textarea>

<label>
<input type="checkbox" id="debug" /> Enable debug logging
Expand Down
69 changes: 3 additions & 66 deletions src/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,58 +196,6 @@ const addHelp = el => {
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelectorAll(".help").forEach(addHelp);

document.querySelector("#print-debug-info").addEventListener("click", () => {
const navigatorInfo = {
appVersion: navigator.appVersion,
userAgent: navigator.userAgent,
language: navigator.language
};

let str = "";
const pp = obj => {
str = str.concat("```json\n" + JSON.stringify(obj, null, 2) + "\n```\n"); // eslint-disable-line
};
const title = name => {
str = str.concat(`\n#### ${name}\n\n`);
};

str = str.concat(
"!⚠! Remove all sensitive information before sharing !⚠!\n\n"
);

str = str.concat("<details>\n<summary>Debug information</summary>\n\n");

str = str.concat(`Generated ${new Date().toISOString()}\n`);

title("Browser");
pp(navigatorInfo);

title("Options");
pp(debugOptions);

title("Extension");
Promise.all([
browser.management.getSelf().then(o => pp({ version: o.version })),
browser.permissions.getAll().then(o => pp({ permissions: o.permissions })),
browser.runtime.getBackgroundPage().then(p => {
title("Globals");
pp({
optionErrors: p.optionErrors,
lastUsedPath: p.lastUsedPath || "null",
lastDownload: p.lastDownload || "null"
});
})
]).then(() => {
str = str.concat("</details>");
const blob = new Blob([str], {
encoding: "UTF-8",
type: "text/plain;charset=UTF-8"
});
const fileObjectURL = URL.createObjectURL(blob);
window.open(fileObjectURL);
});
});

document.querySelector("#reset").addEventListener("click", e => {
/* eslint-disable no-alert */
e.preventDefault();
Expand Down Expand Up @@ -329,26 +277,15 @@ document.querySelectorAll(".popout").forEach(el => {

const showJson = obj => {
const json = JSON.stringify(obj, null, 2);
const blob = new Blob([json], {
encoding: "UTF-8",
type: "application/json"
});
const fileObjectURL = URL.createObjectURL(blob);
window.open(fileObjectURL);
const outputEl = document.querySelector("#export-target");
outputEl.style = "display: unset;";
outputEl.value = json;
};

document.querySelector("#settings-export").addEventListener("click", () => {
showJson(debugOptions);
});

document.querySelector("#show-last-download").addEventListener("click", () => {
browser.runtime.getBackgroundPage().then(w => {
showJson(
w.lastDownloadState || { "Nothing!": "No downloads recorded yet." }
);
});
});

const importSettings = () => {
const load = w => {
getOptionsSchema.then(schema => {
Expand Down
4 changes: 4 additions & 0 deletions src/options/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,7 @@ input.key {
.textcomplete-item.active {
background-color: var(--blue40);
}

#export-target {
width: 100%;
}

0 comments on commit 77fa289

Please sign in to comment.