Skip to content

Commit

Permalink
Add option to only use 2 zoom levels
Browse files Browse the repository at this point in the history
  • Loading branch information
jsh9 committed Nov 27, 2023
1 parent 6d5425a commit da35d94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
14 changes: 13 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,24 @@ function determineNewZoomLevel(
zoomLevel2,
zoomLevel3,
) {
let numbers = [zoomLevel1, zoomLevel2, zoomLevel3];
let numbers = [zoomLevel1, zoomLevel2, zoomLevel3].filter(num => num > 0);

if (numbers.length <= 1) { // there's no need to toggle
return currentZoom;
}

numbers.sort(function (a, b) {
return a - b;
});

if (numbers.length == 2) {
let newZoomLevel = areNumbersClose(currentZoom, numbers[0])
? numbers[1]
: numbers[0];

return newZoomLevel;
}

let newZoomLevel;

if (areNumbersClose(currentZoom, numbers[0])) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Zoom Toggler",
"version": "0.0.6",
"version": "0.0.7",
"description": "Quickly toggle browser page zoom between two levels",
"permissions": [
"storage"
Expand Down
7 changes: 4 additions & 3 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
</head>
<body>
<h3>Zoom levels:</h3>
<p>(If you'd only like to toggle between 2 levels, use -1 as the 3rd level.)</p>
<form id="zoomForm">
<label for="zoom1">Zoom 1:</label>
<input type="number" id="zoom1" min="25" max="500" required /><br />
<input type="number" id="zoom1" min="-1" max="500" required /><br />
<label for="zoom2">Zoom 2:</label>
<input type="number" id="zoom2" min="25" max="500" required /><br />
<input type="number" id="zoom2" min="-1" max="500" required /><br />
<label for="zoom3">Zoom 3:</label>
<input type="number" id="zoom3" min="25" max="500" required /><br />
<input type="number" id="zoom3" min="-1" max="500" required /><br />
<button type="submit">Save</button>
</form>
<div id="status"></div>
Expand Down

0 comments on commit da35d94

Please sign in to comment.