Skip to content

Instantly share code, notes, and snippets.

@kernkraft235
Created December 8, 2025 08:15
Show Gist options
  • Select an option

  • Save kernkraft235/a7cda85f1e9e824780029fb356e8e427 to your computer and use it in GitHub Desktop.

Select an option

Save kernkraft235/a7cda85f1e9e824780029fb356e8e427 to your computer and use it in GitHub Desktop.
Userscript: Anti-Keyboard-Zoom for Safari iOS
// ==UserScript==
// @name Dynamic Anti-AutoZoom
// @namespace vet.skynet.userscripts
// @author userscripts@skynet.vet
// @match *://*/*
// @run-at document-start
// ==/UserScript==
(function () {
function updateRule() {
const scale = window.visualViewport?.scale || 1;
const targetSize = 16 / scale;
const id = 'safari-dynamic-antizoom-style';
document.getElementById(id)?.remove();
const style = document.createElement('style');
style.id = id;
style.textContent = `
input:focus,
textarea:focus,
[contenteditable]:focus {
font-size: ${targetSize}px !important;
line-height: 1.2 !important;
}
`;
document.documentElement.appendChild(style);
}
updateRule();
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', updateRule);
window.visualViewport.addEventListener('scroll', updateRule);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment