MediaWiki:Common.js:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
| 第14行: | 第14行: | ||
const googleUrl = "https://www.google.com/search?q=" + encodeURIComponent(searchTerm); | const googleUrl = "https://www.google.com/search?q=" + encodeURIComponent(searchTerm); | ||
$("<p>").html(`你也可以到 <a href="${googleUrl}" target="_blank" rel="noopener">Google 中搜索“${searchTerm}”</a>。`) | const $googleLink = $("<p>").html( | ||
.insertAfter(".mw-search-results"); | `你也可以到 <a href="${googleUrl}" target="_blank" rel="noopener">Google 中搜索“${searchTerm}”</a>。` | ||
); | |||
// 优先在有搜索结果时插入 | |||
if ($(".mw-search-results").length) { | |||
$googleLink.insertAfter(".mw-search-results"); | |||
} | |||
// 否则在没有结果提示后插入 | |||
else if ($(".mw-search-nonefound").length) { | |||
$googleLink.insertAfter(".mw-search-nonefound"); | |||
} | |||
} | } | ||
}); | }); | ||