TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Randall Munroe's (from xkcd) newest idea

2 点作者 rbmoshe超过 11 年前

2 条评论

bazzargh超过 11 年前
Someone posted similar js when this xkcd was discussed yesterday (<a href="https://news.ycombinator.com/item?id=6696355" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6696355</a>), but also missed that js lets you grab nodesets using xpaths directly:<p><pre><code> var snap = document.evaluate(&#x27;&#x2F;&#x2F;text()&#x27;, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (var i=0;i&lt;snap.snapshotLength; i++) { t=snap.snapshotItem(i); t.textContent = replace(t.textContent); } </code></pre> In addition your code uses \s\s* when you just mean \s+; also you are using case-insensitive matches for the &#x27;dictRegex&#x27; pattern with case-sensitive matches for the individual patterns, so you replace eg &#x27;election&#x27; (lower case e) with &#x27;undefined&#x27;.<p>Like the other js implementation you&#x27;re not matching word boundaries (\b).
评论 #6707768 未加载
rbmoshe超过 11 年前
Time to find a text version of cspan