Skip to content

Commit

Permalink
Workaround .net TLD problem
Browse files Browse the repository at this point in the history
  • Loading branch information
qnighy committed Jul 16, 2023
1 parent 4964b2f commit 50d1efa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ <h2>ソースコード</h2>
<h2>クレジット</h2>
<p>本ツールのアイデアは<a href="https://submarin.online/notes/9gp0trnvll#dialog-dialog">submarin.onlineでの案内を紹介する投稿</a>から着想を得ています。</p>
<p>デフォルトクエリに含まれるサーバーの一覧の作成には<a href="https://w.atwiki.jp/mastodon/">atwikiのマストドンサーバー情報</a><a href="https://fedidb.org/">FediDB</a>などを参考にしました。</p>
<p>Twitterが<code>.net</code> TLDを隠そうとする問題へのワークアラウンドは<a href="https://qnmd.info/@U_cauda_elongata@fedibird.com/110722843034598088" target="_blank" rel="noopener noreferrer">@U_cauda_elongata@fedibird.comのアドバイス</a>を参考にしました。</p>
</body>
</html>
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,21 @@ const DEFAULT_CONDITIONS = {
function generateSearchURL(options = {}) {
const { queryBase, contentConditions } = options;

const searchQuery = `${queryBase} ${Object.keys(contentConditions).filter((condition) => contentConditions[condition]).join(" OR ")}`;
const searchQuery = `${queryBase} ${Object.keys(contentConditions).filter((condition) => contentConditions[condition]).map((query) => workaroundBlockedTLD(query)).join(" OR ")}`;

const url = new URL("https://twitter.com/search");
url.searchParams.set("q", searchQuery);
return url.toString();
}

function workaroundBlockedTLD(query) {
const m = /^url:(.*)\.net$/.exec(query);
if (m) {
return `url:"${m[1]} net"`;
}
return query;
}

const App = () => {
const [queryBase, setQueryBase] = useState("filter:follows");
const conditionsJson = useStorage("conditions");
Expand Down

0 comments on commit 50d1efa

Please sign in to comment.