Skip to content

Instantly share code, notes, and snippets.

@myfonj
Last active January 4, 2024 16:00
Show Gist options
  • Save myfonj/3bdb6bbacd3b080938716495d8989c19 to your computer and use it in GitHub Desktop.
Save myfonj/3bdb6bbacd3b080938716495d8989c19 to your computer and use it in GitHub Desktop.
Dummyze bookmarklet - replace all texts in page with ▒▒▒▒ and images with dummyimage.com counterparts
<p>Bookmarklet:
<a title="Dummyze2" href="javascript:(function (dummyze, entry) {function textWalker(node, cbck) {var i = -1,n, s, w, h;if (!node) {return}if (node.nodeType === 3) {cbck(node, 'nodeValue');return}if (node.tagName == 'IFRAME') {try {textWalker(node.contentDocument.documentElement, cbck)} catch (e) {}return}if (node.tagName == 'STYLE' || node.tagName == 'SCRIPT' || node.tagName == 'SVG') {return}if (node.tagName == 'IMG') {s = getComputedStyle(node);node.src = 'https://dummyimage.com/' + (parseInt(s.width) || 10) + 'x' + (parseInt(s.height) || 10);return}if (node.tagName == 'INPUT' || node.tagName == 'TEXTAREA') {cbck(node, 'placeholder');cbck(node, 'value');return}if (node.tagName) {if ((s = node.getAttribute('style')) &amp;&amp; (s = (s = getComputedStyle(node)).backgroundImage) &amp;&amp; (s != 'none') &amp;&amp; (s = (s.match(/url\(&quot;([^&quot;]+)&quot;\)/))) &amp;&amp; (s = s[1])) {pic = new Image();pic.onload = function () {node.style.backgroundImage = 'url(https://dummyimage.com/' + (parseInt(pic.width) || 10) + 'x' + (parseInt(pic.height) || 10) + ')'};pic.src = s;}if ((b = (b = getComputedStyle(node, '::before')).content) &amp;&amp; (b != 'none') &amp;&amp; b.indexOf('attr(') == 0 &amp;&amp; (b = b.match(/^attr\((.*?)\)$/)) &amp;&amp; (b = b[1])) {cbck(node, b);}if ((b = (b = getComputedStyle(node, '::after')).content) &amp;&amp; (b != 'none') &amp;&amp; b.indexOf('attr(') == 0 &amp;&amp; (b = b.match(/^attr\((.*?)\)$/)) &amp;&amp; (b = b[1])) {cbck(node, b);}while (n = node.childNodes[++i]) textWalker(n, cbck);}};textWalker(entry, dummyze)})(function (n, p, a, w, pic) {p = p || 'nodeValue';a = n[p];if (a) {w = a.replace(/\S/g, '\u2591');if (a != w) n[p] = w} else {a = n.getAttribute &amp;&amp; n.getAttribute(p);if (a) {w = a.replace(/\S/g, '\u2591');if (a != w) n.setAttribute(p, w);}}}, document.documentElement);">Dummyze2</a>
(function (dummyze, entry) {
function textWalker(node, cbck) {
var i = -1,
n, s, w, h;
if (!node) {
return
}
if (node.nodeType === 3) {
cbck(node, 'nodeValue');
return
}
if (node.tagName == 'IFRAME') {
try {
textWalker(node.contentDocument.documentElement, cbck)
} catch (e) {}
return
}
if (node.tagName == 'STYLE' || node.tagName == 'SCRIPT' || node.tagName == 'SVG') {
return
}
if (node.tagName == 'IMG') {
s = getComputedStyle(node);
node.src = 'https://dummyimage.com/' + (parseInt(s.width) || 10) + 'x' + (parseInt(s.height) || 10);
return
}
if (node.tagName == 'INPUT' || node.tagName == 'TEXTAREA') {
cbck(node, 'placeholder');
cbck(node, 'value');
return
}
if (node.tagName) {
if ((s = node.getAttribute('style')) && (s = (s = getComputedStyle(node)).backgroundImage) && (s != 'none') && (s = (s.match(/url\("([^"]+)"\)/))) && (s = s[1])) {
pic = new Image();
pic.onload = function () {
node.style.backgroundImage = 'url(https://dummyimage.com/' + (parseInt(pic.width) || 10) + 'x' + (parseInt(pic.height) || 10) + ')'
};
pic.src = s;
}
if ((b = (b = getComputedStyle(node, '::before')).content) && (b != 'none') && b.indexOf('attr(') == 0 && (b = b.match(/^attr\((.*?)\)$/)) && (b = b[1])) {
cbck(node, b);
}
if ((b = (b = getComputedStyle(node, '::after')).content) && (b != 'none') && b.indexOf('attr(') == 0 && (b = b.match(/^attr\((.*?)\)$/)) && (b = b[1])) {
cbck(node, b);
}
while (n = node.childNodes[++i]) textWalker(n, cbck);
}
};
textWalker(entry, dummyze)
})(function (n, p, a, w, pic) {
p = p || 'nodeValue';
a = n[p];
if (a) {
w = a.replace(/\S/g, '\u2591');
if (a != w) n[p] = w
} else {
a = n.getAttribute && n.getAttribute(p);
if (a) {
w = a.replace(/\S/g, '\u2591');
if (a != w) n.setAttribute(p, w);
}
}
}, document.documentElement);
javascript:(function (dummyze, entry) {function textWalker(node, cbck) {var i = -1,n, s, w, h;if (!node) {return}if (node.nodeType === 3) {cbck(node, 'nodeValue');return}if (node.tagName == 'IFRAME') {try {textWalker(node.contentDocument.documentElement, cbck)} catch (e) {}return}if (node.tagName == 'STYLE' || node.tagName == 'SCRIPT' || node.tagName == 'SVG') {return}if (node.tagName == 'IMG') {s = getComputedStyle(node);node.src = 'https://dummyimage.com/' + (parseInt(s.width) || 10) + 'x' + (parseInt(s.height) || 10);return}if (node.tagName == 'INPUT' || node.tagName == 'TEXTAREA') {cbck(node, 'placeholder');cbck(node, 'value');return}if (node.tagName) {if ((s = node.getAttribute('style')) && (s = (s = getComputedStyle(node)).backgroundImage) && (s != 'none') && (s = (s.match(/url\("([^"]+)"\)/))) && (s = s[1])) {pic = new Image();pic.onload = function () {node.style.backgroundImage = 'url(https://dummyimage.com/' + (parseInt(pic.width) || 10) + 'x' + (parseInt(pic.height) || 10) + ')'};pic.src = s;}if ((b = (b = getComputedStyle(node, '::before')).content) && (b != 'none') && b.indexOf('attr(') == 0 && (b = b.match(/^attr\((.*?)\)$/)) && (b = b[1])) {cbck(node, b);}if ((b = (b = getComputedStyle(node, '::after')).content) && (b != 'none') && b.indexOf('attr(') == 0 && (b = b.match(/^attr\((.*?)\)$/)) && (b = b[1])) {cbck(node, b);}while (n = node.childNodes[++i]) textWalker(n, cbck);}};textWalker(entry, dummyze)})(function (n, p, a, w, pic) {p = p || 'nodeValue';a = n[p];if (a) {w = a.replace(/\S/g, '\u2591');if (a != w) n[p] = w} else {a = n.getAttribute && n.getAttribute(p);if (a) {w = a.replace(/\S/g, '\u2591');if (a != w) n.setAttribute(p, w);}}}, document.documentElement);
@myfonj
Copy link
Author

myfonj commented Jan 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment