mirror of
https://github.com/funkypenguin/geek-cookbook/
synced 2026-09-22 10:17:08 +00:00
Add post on Mastodon CDN
Signed-off-by: David Young <davidy@funkypenguin.co.nz>
This commit is contained in:
@@ -150,5 +150,6 @@
|
||||
"images/blog/multiple-renovate-prs-detail.png": "da36aab8f9c343ffba0b5ddea3982a23da3594c1",
|
||||
"images/blog/haproxy_backends.png": "eded975e1c08c346bad7d4b8177c267a121a503f",
|
||||
"images/blog/haproxy_health_checks.png": "db00b7adafb53286e7083242638155298327c0b3",
|
||||
"images/blog/haproxy_stats-1.png": "3a36d2429c752b8d4612655473820c5bb2146d3f"
|
||||
"images/blog/haproxy_stats-1.png": "3a36d2429c752b8d4612655473820c5bb2146d3f",
|
||||
"images/blog/mastodon_cloudflare_transform_rules.png": "b2552805791734279de05452f4b0f39088a67146"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,65 @@
|
||||
// @ts-check
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @param {() => void} loaded
|
||||
*/
|
||||
var ready = function(loaded) {
|
||||
if (['interactive', 'complete'].indexOf(document.readyState) !== -1) {
|
||||
loaded();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', loaded);
|
||||
}
|
||||
};
|
||||
|
||||
ready(function() {
|
||||
/** @type {Map<number, HTMLIFrameElement>} */
|
||||
var iframes = new Map();
|
||||
|
||||
window.addEventListener('message', function(e) {
|
||||
var data = e.data || {};
|
||||
|
||||
if (typeof data !== 'object' || data.type !== 'setHeight' || !iframes.has(data.id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var iframe = iframes.get(data.id);
|
||||
|
||||
if ('source' in e && iframe.contentWindow !== e.source) {
|
||||
return;
|
||||
}
|
||||
|
||||
iframe.height = data.height;
|
||||
});
|
||||
|
||||
[].forEach.call(document.querySelectorAll('iframe.mastodon-embed'), function(iframe) {
|
||||
// select unique id for each iframe
|
||||
var id = 0, failCount = 0, idBuffer = new Uint32Array(1);
|
||||
while (id === 0 || iframes.has(id)) {
|
||||
id = crypto.getRandomValues(idBuffer)[0];
|
||||
failCount++;
|
||||
if (failCount > 100) {
|
||||
// give up and assign (easily guessable) unique number if getRandomValues is broken or no luck
|
||||
id = -(iframes.size + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iframes.set(id, iframe);
|
||||
|
||||
iframe.scrolling = 'no';
|
||||
iframe.style.overflow = 'hidden';
|
||||
|
||||
iframe.onload = function() {
|
||||
iframe.contentWindow.postMessage({
|
||||
type: 'setHeight',
|
||||
id: id,
|
||||
}, '*');
|
||||
};
|
||||
|
||||
iframe.onload();
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user