javascript:(function(){
/* -------------------------------------------------
STEP 1 — USER CLICKS PARENT CHAT CONTAINER
------------------------------------------------- */
alert("Click the chat container or section you want to start overflow fixing from.");
function clickHandler(ev) {
ev.preventDefault();
ev.stopPropagation();
const start = ev.target;
document.removeEventListener('click', clickHandler, true);
/* -------------------------------------------------
STEP 2 — APPLY OVERFLOW FIX UPWARD
------------------------------------------------- */
let el = start;
while (el && el !== document.documentElement) {
el.style.setProperty('overflow','visible','important');
el.style.setProperty('overflow-y','visible','important');
el.style.setProperty('overflow-x','visible','important');
el.style.setProperty('max-height','none','important');
el.style.setProperty('height','auto','important');
el.style.setProperty('max-width','none','important');
el.style.setProperty('width','auto','important');
el = el.parentElement;
}
alert("Overflow unlocked. Now choose which message to isolate.");
/* -------------------------------------------------
STEP 3 — ASK WHICH MESSAGE NUMBER TO KEEP
------------------------------------------------- */
let n = prompt("Which message number (1 = most recent)?");
if (!n) return;
n = parseInt(n, 10);
if (!n) return;
let msgs = Array.from(
document.querySelectorAll('[data-message-id]')
);
msgs.reverse(); // newest message now index 0
if (n < 1 || n > msgs.length) {
alert("Invalid index");
return;
}
/* -------------------------------------------------
STEP 4 — ISOLATE TARGET MESSAGE
------------------------------------------------- */
msgs.forEach((msg, i) => {
if (i !== (n - 1)) msg.remove();
});
msgs[n - 1].classList.add("target-element-e");
const targets = document.querySelectorAll(".target-element-e");
if (!targets.length) return;
targets.forEach(target => {
// mark descendants
target.querySelectorAll("*").forEach(child =>
child.classList.add("target-element-e")
);
// mark ancestors
let el2 = target;
while (el2) {
el2.classList.add("target-element-e");
el2 = el2.parentElement;
}
});
// hide everything else
document.querySelectorAll("*").forEach(el3 => {
if (!el3.classList.contains("target-element-e")) {
el3.style.display = "none";
}
});
}
document.addEventListener('click', clickHandler, true);
})();
Follow these steps to add a custom JavaScript bookmarklet to Safari on iOS:
javascript:.Here's the structure all bookmarklets follow:
javascript:(function(){
/* your code here */
})();
You can paste any valid JavaScript inside that wrapper.