我希望将这些小书签组合成一个小书签,通过单击书签栏中的小书签来切换图像亮度:
javascript:(function(){!function(e) {e.head.appendChild(e.createElement("style"))
.innerText = ".img,img{-webkit-filter:brightness(50%)}"}(document)})()
和:
javascript:(function(){!function(e) {e.head.appendChild(e.createElement("style"))
.innerText = ".img,img{-webkit-filter:brightness(100%)}"}(document)})()
我尝试自己做,但是我已经很长时间没有使用javascript了,所以我失败了。对于编码或为我指明正确方向的任何帮助,我们将不胜感激。
谢谢!
最佳答案
它通过按“+”或“-”来工作。检查一下:
javascript:(function(d,b,s){s=d.head.appendChild(d.createElement("style"));d.addEventListener('keypress',function(e){if (e. key=='+'&&b<100)b+=10;else if(e.key=='-'&&b>0)b-=10;s.innerText = ".img,img{-webkit-filter:亮度("+b+"%)}"})})(文件,100)
更新:
javascript:(函数(d,id,b,s){s=d.getElementById(id);if (!s)d.head.appendChild(s=d.createElement("style")).id =id;b=s.brightness=150-(s.brightness || 100);s.innerText = ".img,img{-webkit-filter:brightness("+b+"%)}"})(文档, “书签亮度”)
关于javascript - 如何将两个小书签合二为一来切换亮度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52480311/