Skip to content

Instantly share code, notes, and snippets.

@kelbyers
Last active May 15, 2019 02:12
Show Gist options
  • Save kelbyers/1f8285011440141771cfa097415271a9 to your computer and use it in GitHub Desktop.
Save kelbyers/1f8285011440141771cfa097415271a9 to your computer and use it in GitHub Desktop.
bookmarklets
var d = document,
w = window,
E = d.getElementsByTagName('*'),
L = E.length,
D = d.documentElement,
b = d.body,
v = (function () {
// find first element that is actually visible on the page
for (i = 0; i < L; i++) {
if (!E[i].hasChildNodes()) {
var r = E[i].getBoundingClientRect(),
t = r.top,
l = r.left,
e = r.height,
a = r.width;
if ( (e > 0) && (a > 0) &&
(t <= (w.innerHeight || D.clientHeight)) && ((t + e) >= 0) &&
(l <= (w.innerWidth || D.clientWidth)) && ((l + a) >= 0)
) {
return E[i]
}
}
}
})();
for (i = 0; i < L; i++) {
if (E[i].style.fontSize) {
var s = parseInt(E[i].style.fontSize.replace("px", ""));
} else {
var s = 12;
}
s += 2;
E[i].style.fontSize = s + "px"
}
// now make sure previous earliest visible element is still in view
v.scrollIntoView({block:'nearest',inline:'nearest'})
javascript:(function()%7Bvar%20d%3Ddocument%2Cw%3Dwindow%2CE%3Dd.getElementsByTagName(%22*%22)%2CL%3DE.length%2CD%3Dd.documentElement%2Cb%3Dd.body%2Cv%3Dfunction()%7Bfor(i%3D0%3Bi%3CL%3Bi%2B%2B)if(!E%5Bi%5D.hasChildNodes())%7Bvar%20e%3DE%5Bi%5D.getBoundingClientRect()%2Ct%3De.top%2Cn%3De.left%2Cl%3De.height%2Co%3De.width%3Bif(l%3E0%26%26o%3E0%26%26t%3C%3D(w.innerHeight%7C%7CD.clientHeight)%26%26t%2Bl%3E%3D0%26%26n%3C%3D(w.innerWidth%7C%7CD.clientWidth)%26%26n%2Bo%3E%3D0)return%20E%5Bi%5D%7D%7D()%3Bfor(i%3D0%3Bi%3CL%3Bi%2B%2B)%7Bif(E%5Bi%5D.style.fontSize)var%20s%3DparseInt(E%5Bi%5D.style.fontSize.replace(%22px%22%2C%22%22))%3Belse%20s%3D12%3Bs%2B%3D2%2CE%5Bi%5D.style.fontSize%3Ds%2B%22px%22%7Dv.scrollIntoView(%7Bblock%3A%22nearest%22%2Cinline%3A%22nearest%22%7D)%7D)()
var d = document,
w = window,
E = d.getElementsByTagName('*'),
L = E.length,
D = d.documentElement,
b = d.body,
v = (function () {
// find first element that is actually visible on the page
for (i = 0; i < L; i++) {
if (!E[i].hasChildNodes()) {
var r = E[i].getBoundingClientRect(),
t = r.top,
l = r.left,
e = r.height,
a = r.width;
if ( (e > 0) && (a > 0) &&
(t <= (w.innerHeight || D.clientHeight)) && ((t + e) >= 0) &&
(l <= (w.innerWidth || D.clientWidth)) && ((l + a) >= 0)
) {
return E[i]
}
}
}
})();
for (i = 0; i < L; i++) {
if (E[i].style.fontSize) {
var s = parseInt(E[i].style.fontSize.replace("px", ""));
} else {
var s = 12;
}
s += 2;
E[i].style.fontSize = s + "px"
}
// now make sure previous earliest visible element is still in view
v.scrollIntoView({block:'nearest',inline:'nearest'})
javascript:(function()%7Bvar%20d%3Ddocument%2Cw%3Dwindow%2CE%3Dd.getElementsByTagName(%22*%22)%2CL%3DE.length%2CD%3Dd.documentElement%2Cb%3Dd.body%2Cv%3Dfunction()%7Bfor(i%3D0%3Bi%3CL%3Bi%2B%2B)if(!E%5Bi%5D.hasChildNodes())%7Bvar%20e%3DE%5Bi%5D.getBoundingClientRect()%2Ct%3De.top%2Cn%3De.left%2Cl%3De.height%2Co%3De.width%3Bif(l%3E0%26%26o%3E0%26%26t%3C%3D(w.innerHeight%7C%7CD.clientHeight)%26%26t%2Bl%3E%3D0%26%26n%3C%3D(w.innerWidth%7C%7CD.clientWidth)%26%26n%2Bo%3E%3D0)return%20E%5Bi%5D%7D%7D()%3Bfor(i%3D0%3Bi%3CL%3Bi%2B%2B)%7Bif(E%5Bi%5D.style.fontSize)var%20s%3DparseInt(E%5Bi%5D.style.fontSize.replace(%22px%22%2C%22%22))%3Belse%20s%3D12%3Bs-%3D2%2CE%5Bi%5D.style.fontSize%3Ds%2B%22px%22%7Dv.scrollIntoView(%7Bblock%3A%22nearest%22%2Cinline%3A%22nearest%22%7D)%7D)()
var d = document,
w = window,
E = d.getElementsByTagName('*'),
L = E.length,
D = d.documentElement,
b = d.body,
v = (function () {
// find first element that is actually visible on the page
for (i = 0; i < L; i++) {
if (!E[i].hasChildNodes()) {
var r = E[i].getBoundingClientRect(),
t = r.top,
l = r.left,
e = r.height,
a = r.width;
if ( (e > 0) && (a > 0) &&
(t <= (w.innerHeight || D.clientHeight)) && ((t + e) >= 0) &&
(l <= (w.innerWidth || D.clientWidth)) && ((l + a) >= 0)
) {
return E[i]
}
}
}
})();
for (i = 0; i < L; i++) {
if (E[i].style.fontSize) {
var s = parseInt(E[i].style.fontSize.replace("px", ""));
} else {
var s = 12;
}
s -= 2;
E[i].style.fontSize = s + "px"
}
// now make sure previous earliest visible element is still in view
v.scrollIntoView({block:'nearest',inline:'nearest'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment