tig
https://lh3.googleusercontent.com/a-/AOh14GgdSSCo3ooeyyoaIvFBPykXmIVyprXdJ7IImAUi#.png
this is tig’s page
code:script.js
const query = "*"+gifURLs.map(gifURL => [src="${gifURL}"]).join(",");
const observer = new MutationObserver(records => {
records.forEach(({type,target,addedNodes})=>{
switch(type){
case "attributes":
if(gifURLs.includes(target.src)){
freeze_gif(target);
}
break;
case "childList":
if(gifURLs.includes(element.src)){
}
return r;
}).forEach(element=>{
freeze_gif(element);
});
break;
}
});
})
observer.observe(document.body, {
attributes: true,
childList: true,
subtree: true
});
console.error("start observe");
document.querySelectorAll(query).forEach(element=>{
freeze_gif(element);
});
window.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll(query).forEach(element=>{
freeze_gif(element);
});
});
function freeze(i){
var c = document.createElement('canvas');
var w = c.width = i.width;
var h = c.height = i.height;
c.getContext('2d').drawImage(i, 0, 0, w, h);
try {
i.src = c.toDataURL("image/gif"); // if possible, retain all css aspects
} catch(err) {
i.parentNode.replaceChild(c, i);
}
console.error("freezed");
}
function freeze_gif(i) {
console.log(i);
if(i.complete){
freeze(i);
}else{
i.addEventListener("load",()=>{
freeze(i)
});
}
}