样式修改

This commit is contained in:
example 2019-02-15 13:38:48 +08:00
parent 268f4b568c
commit 75b66be261

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name 划词翻译:多词典查询 // @name 划词翻译:多词典查询
// @namespace http://tampermonkey.net/ // @namespace http://tampermonkey.net/
// @version 2.2 // @version 2.3
// @description 划词翻译调用“有道词典有道翻译、金山词霸、Bing 词典必应词典、剑桥高阶、沪江小D、谷歌翻译” // @description 划词翻译调用“有道词典有道翻译、金山词霸、Bing 词典必应词典、剑桥高阶、沪江小D、谷歌翻译”
// @author https://github.com/barrer // @author https://github.com/barrer
// @match http://*/* // @match http://*/*
@ -292,6 +292,14 @@
list-style: none; list-style: none;
} }
.hjenglish dd {
margin-left: 1em;
}
.hjenglish dd>p {
margin-left: 2.5em;
}
.bing h1, .bing h1,
.bing strong { .bing strong {
font-size: 1em; font-size: 1em;
@ -376,6 +384,11 @@
display: inline; display: inline;
} }
.bing .idm_seg,
.bing .li_ids_co {
margin-left: 1em;
}
.cambridge .entry~.entry { .cambridge .entry~.entry {
margin-top: 1em; margin-top: 1em;
} }
@ -409,6 +422,7 @@
border: 1px solid #777; border: 1px solid #777;
border-radius: .5em; border-radius: .5em;
padding: 0 2px; padding: 0 2px;
font-size: .8em;
} }
.cambridge .examp, .cambridge .examp,
@ -423,14 +437,8 @@
margin-top: 1em; margin-top: 1em;
} }
.cambridge .pos::before { .cambridge .pos-body {
content: "["; margin-left: 1em;
padding-right: 3px;
}
.cambridge .pos::after {
content: "]";
padding-left: 3px;
} }
`; `;
// iframe 工具库 // iframe 工具库
@ -467,8 +475,8 @@
CAMBRIDGE: 'cambridge' CAMBRIDGE: 'cambridge'
}; };
var idsExtension = { var idsExtension = {
LIST_DICT: [ids.BING, ids.CAMBRIDGE, ids.HJENGLISH, ids.ICIBA, ids.YOUDAO], LIST_DICT: [ids.BING, ids.HJENGLISH, ids.CAMBRIDGE, ids.ICIBA, ids.YOUDAO],
LIST_DICT_LOWER_CASE: [ids.BING, ids.BING_LOWER_CASE, ids.CAMBRIDGE, ids.HJENGLISH, ids.ICIBA, ids.ICIBA_LOWER_CASE, ids.YOUDAO, ids.YOUDAO_LOWER_CASE], LIST_DICT_LOWER_CASE: [ids.BING, ids.BING_LOWER_CASE, ids.HJENGLISH, ids.CAMBRIDGE, ids.ICIBA, ids.ICIBA_LOWER_CASE, ids.YOUDAO, ids.YOUDAO_LOWER_CASE],
LIST_GOOGLE: [ids.GOOGLE], LIST_GOOGLE: [ids.GOOGLE],
lowerCaseMap: (function () { lowerCaseMap: (function () {
var obj = {}; var obj = {};
@ -1154,6 +1162,7 @@
dom.setAttribute('class', ids.HJENGLISH); dom.setAttribute('class', ids.HJENGLISH);
try { try {
var doc = htmlToDom(cleanHtml(rst)); var doc = htmlToDom(cleanHtml(rst));
var label = doc.querySelector('.word-details-item-content header');
var entry = doc.querySelector('.word-text h2'); var entry = doc.querySelector('.word-text h2');
var collins = doc.querySelector('div[data-id="detail"] .word-details-item-content .detail-groups'); var collins = doc.querySelector('div[data-id="detail"] .word-details-item-content .detail-groups');
if (entry) { if (entry) {
@ -1162,7 +1171,13 @@
entryDom.innerHTML = entry.innerHTML; entryDom.innerHTML = entry.innerHTML;
dom.appendChild(entryDom); dom.appendChild(entryDom);
if (collins) { if (collins) {
dom.appendChild(htmlToDom('<div>《权威词典》</div>')); if (label) {
var regex = /(《.*?》)/ig;
var match = regex.exec(label.innerHTML);
if (match && match[1]) {
dom.appendChild(htmlToDom('<div>' + match[1] + '</div>'));
}
}
dom.appendChild(collins); dom.appendChild(collins);
} }
} }