JS书签:增加/减少站点的字体大小

I was using the code from here to enlargen sites:


var p=document.getElementsByTagName('*');

for(i=0;i<p.length;i++) {
  if(p[i].style.fontSize){
    var s=parseInt(p[i].style.fontSize.replace("px",""));
}
else {
  var s=12;
}

s+=2;
p[i].style.fontSize=s+"px"

But this has recently stopped working on my Chrome (Version 81.0.4044.138 (Official Build) (64-bit)). I am curious as to why, and any working alternatives.

评论
菊花怒放
菊花怒放

Define stopped working

它按预期工作。

var p = document.getElementsByTagName('*');

for (i = 0; i < p.length; i++) {
  if (p[i].style.fontSize) {
    var s = parseInt(p[i].style.fontSize.replace("px", ""));
  } else {
    var s = 12;
  }

  s += 2;
  p[i].style.fontSize = s + "px"
}
<p id="test">test</p>
点赞
评论