Skip to content

Commit

Permalink
3.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lkytal committed Jan 11, 2016
1 parent c547037 commit cd9d72d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ GM的"用户脚本设置"下的"Popup Search设置"打开选项选择需要的

Update Log:

* 3.2.5 : Translation fixup for large texts
* 3.2.4 : Multiline fixup
* 3.2.3 : fix popup position
* 3.2.2 : Multiline fixup
* 3.2.1 : fix translation
* 3.2.0 : transform to Youdao
* 3.1.7 : Ip fix
* 3.1.6 : Ip Updated
* 3.1.5 : no jquery conflicts
* 3.1.4 : fix Background mode for chrome
Expand Down
2 changes: 1 addition & 1 deletion meta/popsearch.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// @exclude http://acid3.acidtests.org/*
// @exclude http://www.acfun.tv/*
// @require http://libs.baidu.com/jquery/2.1.3/jquery.min.js
// @version 3.2.4
// @version 3.2.5
// @icon http://lkytal.qiniudn.com/ic.ico
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
Expand Down
2 changes: 1 addition & 1 deletion meta/scroll.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// @include *
// @exclude *pan.baidu.com/*
// @exclude *c5.yunpan.360.cn/*
// @version 1.4.0
// @version 1.4.1
// @icon http://lkytal.qiniudn.com/ic.ico
// @grant GM_getValue
// @grant GM_setValue
Expand Down
51 changes: 40 additions & 11 deletions popsearch.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// @exclude http://acid3.acidtests.org/*
// @exclude http://www.acfun.tv/*
// @require http://libs.baidu.com/jquery/2.1.3/jquery.min.js
// @version 3.2.4
// @version 3.2.5
// @icon http://lkytal.qiniudn.com/ic.ico
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
Expand All @@ -28,7 +28,7 @@
// ==/UserScript==

"use strict";
var GetOpt, InTextBox, Init, Load, OpenSet, SaveOpt, SetOpt, SettingWin, ShowBar, TimeOutHide, addCSS, fixPos, getLastRange, get_offsets_and_remove, get_selection_offsets, log, popData, praseTranslation,
var GetOpt, InTextBox, Init, Load, OpenSet, SaveOpt, SetOpt, SettingWin, ShowBar, TimeOutHide, addCSS, fixPos, getLastRange, get_offsets_and_remove, get_selection_offsets, log, popData, praseTranslation, praseTranslationMore,
hasProp = {}.hasOwnProperty;

this.$ = this.jQuery = jQuery.noConflict(true);
Expand Down Expand Up @@ -169,16 +169,28 @@ Init = function() {
$('#popupwapper').hide();
fixPos(document.defaultView.getSelection());
callback = function(err) {
return console.log(err);
console.log(err);
return $('#Gspan').empty().append("Error:\n" + err).show();
};
GM_xmlhttpRequest({
method: 'GET',
timeout: 4000,
url: "http://fanyi.youdao.com/openapi.do?keyfrom=tinxing&key=1312427901&type=data&doctype=json&version=1.1&q=" + popData.text,
onload: praseTranslation,
onerror: callback,
ontimeout: callback
});
if (popData.text.length < 380) {
GM_xmlhttpRequest({
method: 'GET',
timeout: 3000,
url: "http://fanyi.youdao.com/openapi.do?keyfrom=tinxing&key=1312427901&type=data&doctype=json&version=1.1&q=" + popData.text,
onload: praseTranslation,
onerror: callback,
ontimeout: callback
});
} else {
GM_xmlhttpRequest({
method: 'GET',
timeout: 3000,
url: "http://fanyi.baidu.com/transapi?from=auto&to=auto&query=" + popData.text,
onload: praseTranslationMore,
onerror: callback,
ontimeout: callback
});
}
return event.preventDefault();
});
if (GetOpt('Dis_st')) {
Expand Down Expand Up @@ -215,6 +227,23 @@ praseTranslation = function(responseDetails) {
fixPos(document.defaultView.getSelection());
};

praseTranslationMore = function(responseDetails) {
var Result, Rline, Rtxt, i, len, lines, ref;
if (!popData.bTrans) {
return;
}
Rtxt = JSON.parse(responseDetails.responseText);
Rline = "";
ref = Rtxt.data;
for (i = 0, len = ref.length; i < len; i++) {
lines = ref[i];
Rline += lines.dst + "<br>";
}
Result = "<div id=\"tranRst\" style=\"font-size:13px;overflow:auto;padding:5px 15px;\">\n <p style=\"line-height:180%;font-size:13px;\">\n " + Rline + "\n </p>\n</div>";
$('#Gspan').empty().append(Result).show();
fixPos(document.defaultView.getSelection());
};

$(document).on("mouseup", function(event) {
if (event.which !== 1) {
return;
Expand Down
5 changes: 4 additions & 1 deletion scroll.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// @include *
// @exclude *pan.baidu.com/*
// @exclude *c5.yunpan.360.cn/*
// @version 1.4.0
// @version 1.4.1
// @icon http://lkytal.qiniudn.com/ic.ico
// @grant GM_getValue
// @grant GM_setValue
Expand Down Expand Up @@ -159,6 +159,9 @@ function scrollPlus()
background-color: rgba(0, 0, 0, 0.3);\
color: #fff;\
text-decoration: none;\
-moz-user-select:none;\
-webkit-user-select:none;\
cursor:default;\
}\
#scrollUpIco:hover {\
background-color: rgba(0, 0, 0, 0.75);\
Expand Down

0 comments on commit cd9d72d

Please sign in to comment.