MetaFilter embiggen small hyperlinks

Makes small hyperlinks in comments on MetaFilter.com and all subsites larger. Helpful on mobile devices.

当前为 2019-08-23 提交的版本,查看 最新版本

// ==UserScript==
// @name          MetaFilter embiggen small hyperlinks
// @description	  Makes small hyperlinks in comments on MetaFilter.com and all subsites larger. Helpful on mobile devices.
// @author        Tehhund
// @match         *://*.metafilter.com/*
// @run-at        document-idle
// @version       7
// @namespace https://gf.qytechs.cn/users/324881
// ==/UserScript==

function embiggen() {
  let allHyperlinks = [];
  let allCommentDivs = document.getElementsByClassName('comments');
  allCommentDivs = Array.from(allCommentDivs).filter( function(div) { return div.previousSibling.tagName == 'A'; }); // Some "comment" divs are actually not comments. Real comments are always preceded by an anchor tag so this filters out any not-actually-comment divs.
  for (currentDiv of allCommentDivs) { // get all the hyperlinks from within comment divs.
    allLinksInCurrentDiv = Array.from(currentDiv.getElementsByTagName('A'));
    allHyperlinks = allHyperlinks.concat(allLinksInCurrentDiv);
  }
  for (let tag of allHyperlinks) { // Check hyperlink font size and increase if it's less than 17px
  	  let compStyles = window.getComputedStyle(tag);
  	  let compFontSize = parseFloat(compStyles.getPropertyValue('font-size'));
    if (compFontSize < 17) tag.style.fontSize = '130%';
  }
}

// Observe the main content div for changes such as new comments or adding a Favorite, and run embiggen() again.
// Temporarily removing due to performance issues. Will reenable if I can find a performant way to do this.
//const mutationObserver = new //MutationObserver(embiggen);
//mutationObserver.observe(document.getElementById('posts'), { attributes: true, childList: true, subtree: true })

embiggen();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址