Skip to content

Commit

Permalink
✨ Add "Unset PAC script" button
Browse files Browse the repository at this point in the history
  • Loading branch information
younesaassila committed Oct 5, 2023
1 parent fd76639 commit 111f0cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/options/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import $ from "../common/ts/$";
import { readFile, saveFile } from "../common/ts/file";
import getProxyInfoFromUrl from "../common/ts/getProxyInfoFromUrl";
import isChromium from "../common/ts/isChromium";
import { updateProxySettings } from "../common/ts/proxySettings";
import {
clearProxySettings,
updateProxySettings,
} from "../common/ts/proxySettings";
import sendAdLog from "../common/ts/sendAdLog";
import store from "../store";
import getDefaultState from "../store/getDefaultState";
Expand Down Expand Up @@ -71,6 +74,9 @@ const adLogClearButtonElement = $("#ad-log-clear-button") as HTMLButtonElement;
const exportButtonElement = $("#export-button") as HTMLButtonElement;
const importButtonElement = $("#import-button") as HTMLButtonElement;
const resetButtonElement = $("#reset-button") as HTMLButtonElement;
const unsetPacScriptButtonElement = $(
"#unset-pac-script-button"
) as HTMLButtonElement;
//#endregion

const DEFAULT_STATE = Object.freeze(getDefaultState());
Expand Down Expand Up @@ -170,6 +176,9 @@ function main() {
store.state.adLogEnabled = adLogEnabledCheckboxElement.checked;
});
}
if (!isChromium) {
unsetPacScriptButtonElement.style.display = "none";
}
}

function isOptimizedProxyUrlAllowed(url: string): AllowedResult {
Expand Down Expand Up @@ -503,3 +512,10 @@ resetButtonElement.addEventListener("click", () => {
store.clear();
window.location.reload(); // Reload page to update UI.
});

unsetPacScriptButtonElement.addEventListener("click", () => {
if (isChromium) {
clearProxySettings();
alert("PAC script unset successfully.");
}
});
1 change: 1 addition & 0 deletions src/options/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ <h2>Ad log</h2>
<button id="export-button">Back up to file…</button>
<button id="import-button">Restore from file…</button>
<button id="reset-button">Reset to default settings…</button>
<button id="unset-pac-script-button">Unset PAC script</button>
</section>
</main>

Expand Down
1 change: 1 addition & 0 deletions src/options/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ input[type="text"]::placeholder {

input[type="button"],
button {
margin: 0.125rem 0;
padding: 0.5rem 1rem;
border: 0;
border-radius: 6px;
Expand Down

0 comments on commit 111f0cb

Please sign in to comment.