|
|
| 第151行: |
第151行: |
| // 再加一个延时 | | // 再加一个延时 |
| setTimeout(removeBetaNotice, 2000); | | setTimeout(removeBetaNotice, 2000); |
| });
| |
|
| |
|
| |
| // 正文底部额外搜索链接
| |
| mw.hook('wikipage.content').add(function ($content) {
| |
| // 只在默认命名空间生效,且排除首页
| |
| if (mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgIsMainPage')) {
| |
| return;
| |
| }
| |
|
| |
| // 获取条目标题
| |
| var pageName = mw.config.get('wgPageName');
| |
| var title = pageName.replace(/_/g, ' ');
| |
|
| |
| // 外部搜索链接配置
| |
| var links = [
| |
| { text: '谷歌搜索', url: 'https://www.google.com/search?q=' + encodeURIComponent(title) },
| |
| { text: '百度搜索', url: 'https://www.baidu.com/s?wd=' + encodeURIComponent(title) }
| |
| ];
| |
|
| |
| // 构建容器
| |
| var container = $('<div>')
| |
| .addClass('cdx-search-links')
| |
| .css({ marginTop: '20px', textAlign: 'center' });
| |
|
| |
| // 添加提示
| |
| container.append(
| |
| $('<div>')
| |
| .css({ marginBottom: '8px', fontWeight: 'bold' })
| |
| .text('在外部搜索条目:' + title)
| |
| );
| |
|
| |
| // 遍历添加链接
| |
| links.forEach(function (link) {
| |
| var a = $('<a>')
| |
| .addClass('cdx-docs-link is-underlined')
| |
| .attr('href', link.url)
| |
| .attr('target', '_blank')
| |
| .css({ margin: '0 10px' })
| |
| .text(link.text + ' ');
| |
|
| |
| // 添加外部链接图标(采用 Codex 的外链图标 class)
| |
| var icon = $('<span>')
| |
| .addClass('cdx-icon cdx-icon--small cdx-icon-link-external');
| |
|
| |
| a.append(icon);
| |
| container.append(a);
| |
| });
| |
|
| |
| $content.append(container);
| |
| }); | | }); |