Greasy Fork

来自缓存

Greasy Fork is available in English.

在 bing词典 中聚合显示 有道 的结果 添加转跳至 linggle 和 ludwig 的按钮

1. Display youdao.com results alongside the original results on bing.com/dict. 2. Provide shortcuts for linggle and ludwig.

当前为 2022-03-30 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         在 bing词典 中聚合显示 有道 的结果 添加转跳至 linggle 和 ludwig 的按钮
// @namespace    http://tampermonkey.net/
// @version      4.0
// @license      MIT
// @description  1. Display youdao.com results alongside the original results on bing.com/dict. 2. Provide shortcuts for linggle and ludwig.
// @author       庶民player
// @match        *.bing.com/dict*
// @icon         https://cn.bing.com/sa/simg/favicon-2x.ico
// @require      https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
// @run-at       document-idle
// @compatible   edge
// @compatible   chrome
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var wd = "none"
    var qry = window.location.search.substring(1);
    var vals = qry.split('&');
    for(var i in vals){
        var pair = vals[i].split('=');
        if(pair[0] == "q") wd = pair[1];
    }

//-=-=-=-=-=-=-=-=-=-=-=-=-以下显示各种按钮-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    const linggle_button = document.createElement('button');
	linggle_button.className = 'btn btn-sm';
	$(linggle_button).css({
        "border":"0",
        "background-color":"transparent",
        "cursor": "pointer",
        "position": "absolute",
        "left": ($("#b_header").position().left + 55) +"px",
        "top": ($("#b_header").position().top + $("#b_header").height() - 12) + "px",
    });
    linggle_button.innerHTML = `
        <img
            src="https://www.linggle.com/linggle-logo.png"
            alt="linggle-logo"
            width=`+ parseInt($(".b_logo").width()*0.6) +`px
        />
    `;
	linggle_button.onclick = function() {
		location.href = "https://www.linggle.com/?q=" + wd;
	}
    document.body.append(linggle_button);


    const ludwig_button = document.createElement('button');
	ludwig_button.className = 'btn btn-sm';
	$(ludwig_button).css({
        "border":"0",
        "background-color":"transparent",
        "cursor": "pointer",
        "position": "absolute",
        "left": ($("#b_header").position().left + 15) +"px",
        "top": ($("#b_header").position().top + $("#b_header").height() - 23) + "px",
    });
    ludwig_button.innerHTML = `
        <img
            src="https://ludwig.guru/icons/icon_144x144.png"
            alt="ludwig-logo"
            height=`+ parseInt($(".b_logo").height()*2.0) +`px
        />
    `;
	ludwig_button.onclick = function() {
		location.href = "https://ludwig.guru/s/" + wd;
	}
    document.body.append(ludwig_button);

//-=-=-=-=-=-=-=-=-=-=-=-=-=-以下显示有道-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    if(wd.length > 50) return;

    var youdao_top_padding = 190;
    var youdao_left_padding = 120;
    var youdao_width = 640;
    var bing_width = $(".lf_area").width(); //532
    var margin = window.innerWidth -youdao_width -bing_width;

    $("#b_footer").css("display", "none");
    $(".sidebar").css("display", "none");
    $(".lf_area").css({
        "position": "absolute",
        "left": parseInt(margin * 0.34)+"px",
    });

    let m = `
        <div
            style="
                overflow: hidden;
                position: absolute;
                right:`+ parseInt(margin * 0.16) +`px;
                top: `+ $(".contentPadding").position().top +`px;
                width:`+ youdao_width +`px;
            "
        >
            <iframe
                style="
                    position:relative;
                    top: `+ (-youdao_top_padding) +`px
                "
                src="https://dict.youdao.com/w/` + wd + `"
                frameborder=0
                scrolling="no"
                width="` + (youdao_left_padding + youdao_width) + `px"
                height="` + $(document).height() + `px"
            >
            </iframe>
        </div>
    `
    $(m).appendTo(document.body)
})();