Skip to content

Instantly share code, notes, and snippets.

@0rShemesh
Last active February 1, 2025 17:46
Show Gist options
  • Save 0rShemesh/7d141b761e83756e9d09a37881c2fa35 to your computer and use it in GitHub Desktop.
Save 0rShemesh/7d141b761e83756e9d09a37881c2fa35 to your computer and use it in GitHub Desktop.
safari_zoomnono.js
// ==UserScript==
// @name No Zoom on iOS
// @namespace Violentmonkey Scripts
// @icon https://cdn.oaistatic.com/_next/static/media/apple-touch-icon.59f2e898.png
// @match *://*/*
// @grant none
// @noframes
// @version 0.1.2
// @author y-saeki
// @supportURL https://github.com/y-saeki/UserScript
// @description disable input form auto-zoom function on iOS
// @downloadURL https://update.greasyfork.org/scripts/478562/No%20Zoom%20on%20iOS.user.js
// @updateURL https://update.greasyfork.org/scripts/478562/No%20Zoom%20on%20iOS.meta.js
// ==/UserScript==
check();
// Observe Screen Transition
const observeTarget = document.querySelector('head');
const observer = new MutationObserver(check);
observer.observe(observeTarget, { childList: true });
// Runs everytime when mutated
function check() {
const viewportMeta = document.querySelector('meta[name="viewport"]');
if (viewportMeta) {
const content = viewportMeta.getAttribute("content");
if (content) {
if (!content.includes("user-scalable=no")) {
viewportMeta.setAttribute(
"content",
content + ", user-scalable=no"
);
}
} else {
viewportMeta.setAttribute("content", "user-scalable=no");
}
} else {
const newViewportMeta = document.createElement("meta");
newViewportMeta.name = "viewport";
newViewportMeta.content = "user-scalable=no";
document.getElementsByTagName("head")[0].appendChild(newViewportMeta);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment