Greasy Fork

Greasy Fork is available in English.

bing搜索-日历增强

当bing搜索‘日历’相关内容时,在搜索结果集最顶端显示日历

当前为 2019-04-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         bing搜索-日历增强
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  当bing搜索‘日历’相关内容时,在搜索结果集最顶端显示日历
// @author       yankj12
// @match        *://cn.bing.com/search*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 定位到搜索框,获取到搜索框中的值,如果包含“日历”,则使用日历增强功能
    var searchbox = document.querySelector('.b_searchbox');
    var keyword = '';
    if(searchbox !== null){
        keyword = searchbox.value;
    }
    //console.log(keyword);

    if(keyword.indexOf('日历') > -1){
        // 判断关键字是否包含“日历”
        console.log('搜索关键词包含“日历”二字');
        // 定位到搜索结果集,在搜索结果集最顶端显示日历
        var resultBox = document.getElementById('b_results');
        var topItem = resultBox.firstChild;

        // 通过iframe的方式引入其他网页的日历
        // 目前日历引用自https://www.hao123.com/rili
        var iframe = document.createElement('iframe');
        iframe.id = 'app-extension-frame';
        iframe.src = 'https://www.hao123.com/rili';
        iframe.width = 1000;
        iframe.height = 800;
        resultBox.insertBefore(iframe, topItem);

        // 移除侧边栏,否则会挡着日历
        var as = document.querySelector('aside');
        as.innerHTML = '';
    }
})();