기능구현/최초커밋

This commit is contained in:
dahyeon committed 2025-09-15 15:56:44 +09:00
commit f6b12ad915
514 files changed
+680533

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
function u(e){const r=document.createElement("canvas"),t=r.getContext("2d"),s=50,c=Math.max(1,Math.floor(e.naturalHeight/e.naturalWidth*s));r.width=s,r.height=c;try{if(!t)return console.log("브라우저에서 canvas 컨텍스트를 찾지 못했습니다."),console.log("이미지 밝기를 0으로 간주합니다."),0;t.drawImage(e,0,0,s,c);const n=t.getImageData(0,0,s,c).data;let a=0,h=0,l=0,d=0;for(let o=0;o<n.length;o+=4)a+=n[o],h+=n[o+1],l+=n[o+2],d++;return(a+h+l)/(d*3)}catch{return 255}}function b(e,r){e.style.filter=`brightness(${r})`}function i(e,r){document.querySelectorAll("img[src^='blob:']").forEach(t=>{if(t.dataset.filterChecked)return;t.dataset.filterChecked="true";const s=()=>{u(t)>r&&b(t,e)};t.complete?s():t.addEventListener("decode",s)})}chrome.storage.sync.get({brightnessFactor:.8,brightnessThreshold:200},e=>{i(e.brightnessFactor,e.brightnessThreshold),new MutationObserver(()=>{i(e.brightnessFactor,e.brightnessThreshold)}).observe(document.body,{childList:!0,subtree:!0})});
//# sourceMappingURL=content.js.map