代码片段
使用 js,让 link icon 根据锚文本来选择是否显示
function link_icon_filter() {
let spans = document.querySelectorAll('span[data-type="a"]');
spans.forEach(span => {
const isWrappedInBracketsOrNumber = /\[.+?\]|^\d+$/.test(span.textContent);
if (span.textContent === '*' || isWrappedInBracketsOrNumber) {
span.setAttribute('custom-link-icon', 'true');
}
else {
span.removeAttribute('custom-link-icon');
}
});
}
linkIconFilterInterval = setInterval(link_icon_filter, 100);
功能
- 锚文本为数字不显示 link icon
- 锚文本为*不显示 link icon
- 锚文本被[]包裹,不显示 link icon
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于