Skip to content

Commit

Permalink
🎨 Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 27, 2023
1 parent 8eedef9 commit 8ee5a84
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: fix-byte-order-marker
Expand All @@ -25,7 +25,7 @@ repos:
hooks:
- id: remove-crlf
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
Expand All @@ -37,19 +37,19 @@ repos:
args:
- --msg-filename
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.2
rev: 2.7.3
hooks:
- id: editorconfig-checker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: check-mailmap
- repo: https://github.com/rhysd/actionlint
rev: v1.6.25
rev: v1.6.26
hooks:
- id: actionlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
rev: v1.33.0
hooks:
- id: yamllint
- repo: https://github.com/executablebooks/mdformat
Expand All @@ -66,8 +66,8 @@ repos:
- mdformat-black
- mdformat-config
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.9.2
rev: v0.11.0
hooks:
- id: markdownlint-cli2
additional_dependencies:
- markdown-it-texmath@0.9.1
- markdown-it-texmath
40 changes: 20 additions & 20 deletions fit-the-screen-consisting-of-two-monitors.user.js
Expand Up @@ -15,48 +15,48 @@
(function () {
"use strict";

let short_parents = new Set();
function get_short_parents(elem) {
if (elem.offsetWidth == 0 || elem.offsetHeight == 0) {
return;
}
// all non-empty elements' parents
let parents = new Set();
function get_parents(elem) {
// skip empty elements
if (elem.offsetWidth || elem.offsetHeight == 0) return;
if (elem.offsetWidth < window.innerWidth) {
short_parents.add(elem.parentElement);
parents.add(elem.parentElement);
return;
}
Array.from(elem.children).forEach(function (elem) {
get_short_parents(elem);
});
for (const child of elem.children) get_parents(child);
}
let body = document.getElementsByTagName("body")[0];
get_short_parents(body);
get_parents(body);

let short_elements = new Set();
short_parents.forEach(function (elem) {
let elements = new Set();
for (const parent of parents) {
let min_offsetLeft = window.innerWidth;

let short_element = null;
Array.from(elem.children).forEach(function (elem) {
for (const elem of parent.children) {
// skip empty elements
if (elem.offsetWidth || elem.offsetHeight == 0) continue;
if (
elem.offsetHeight > 0 &&
elem.offsetWidth > 0 &&
elem.offsetLeft > window.innerWidth / 4 &&
elem.offsetWidth < (2 * window.innerWidth) / 3 &&
min_offsetLeft > elem.offsetLeft
) {
min_offsetLeft = elem.offsetLeft;
short_element = elem;
}
});
}

if (short_element != null) {
short_elements.add(short_element);
elements.add(short_element);
}
});
}

short_elements.forEach(function (elem) {
for (const elem of elements) {
let default_left = "5rem";
if (elem.offsetWidth < window.innerWidth / 4) {
default_left = "10rem";
}
elem.style.marginLeft = default_left;
});
}
})();

0 comments on commit 8ee5a84

Please sign in to comment.