diff --git a/CHANGELOG.md b/CHANGELOG.md index 14ffa66..5d2895e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,159 +4,160 @@ All notable changes to all the scripts will be documented in this file. ## Popup Search -* 4.2.3 : Use data property instead of href. -* 4.2.2 : Exclude `Furk.net`. -* 4.2.1 : Fix http prefix. -* 4.2.0 : Won't trigger within search area. -* 4.1.6 : Respect tab setting for user engines -* 4.1.5 : Ensure right click copy -* 4.1.3 : Update icon and jquery -* 4.1.2 : Fix false popup in chrome -* 4.1.1 : Fixup incorrect customization -* 4.1.0 : New: customization -* 4.0.8 : Retry when translate timeout -* 4.0.7 : Unwanted popup in textbox in chrome -* 4.0.6 : Fix userEngine Error -* 4.0.5 : Switch back to google translation -* 4.0.4 : Fixed open as link -* 4.0.3 : Add DouBan engine -* 4.0.2 : Fixed open as link and style in v2ex -* 4.0.1 : Better performance -* 4.0.0 : New setting UI with many new engines -* 3.5.0 : Setting enhancement -* 3.4.0 : Fix hidden problem -* 3.3.3 : Better position locating -* 3.3.1 : Update jquery -* 3.3.0 : Position problem in chrome -* 3.2.9 : Update to jquery v3 -* 3.2.8 : Fix multi tabs -* 3.2.7 : Update to jQuery 3.1.0 -* 3.2.6 : Auto copying in chrome -* 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 -* 3.1.3 : Background mode -* 3.1.2 : Fix translation -* 3.1.0 : Iframe support -* 3.0.5 : TaoBao fix -* 3.0.4 : Mouseup event -* 3.0.3 : Css fix -* 3.0.2 : New setting box -* 3.0.0 : UI redesigned -* 2.9.7 : Google Page -* 2.9.5 : Setting window -* 2.9.1 : In site search fix up -* 2.9.0 : In site search added -* 2.8.5 : Translate sync -* 2.8.4 : Cleanup -* 2.8.2 : Better css style -* 2.8.1 : Multiply translate address -* 2.8.0 : More translation methods -* 2.7.5 : Exclude test pages -* 2.7.4 : Fix up -* 2.7.3 : UI improvement -* 2.7.2 : Update method change -* 2.7.1 : Meta info added -* 2.7.0 : Switch to git -* 2.6.8 : New setting window -* 2.6.7 : New style code -* 2.6.6 : Clean up codes -* 2.6.5 : Update translation -* 2.6.4 : Improve css style -* 2.6.3 : Rewritten translation part. -* 2.6.2 : Add failsafe translation -* 2.6.1 : Fix Popup size -* 2.6.0 : Update Jquery +* 4.2.4: Option to hide translator; fix for violentMonkey. +* 4.2.3: Use data property instead of href. +* 4.2.2: Exclude `Furk.net`. +* 4.2.1: Fix http prefix. +* 4.2.0: Won't trigger within search area. +* 4.1.6: Respect tab setting for user engines +* 4.1.5: Ensure right click copy +* 4.1.3: Update icon and jquery +* 4.1.2: Fix false popup in chrome +* 4.1.1: Fixup incorrect customization +* 4.1.0: New: customization +* 4.0.8: Retry when translate timeout +* 4.0.7: Unwanted popup in textbox in chrome +* 4.0.6: Fix userEngine Error +* 4.0.5: Switch back to google translation +* 4.0.4: Fixed open as link +* 4.0.3: Add DouBan engine +* 4.0.2: Fixed open as link and style in v2ex +* 4.0.1: Better performance +* 4.0.0: New setting UI with many new engines +* 3.5.0: Setting enhancement +* 3.4.0: Fix hidden problem +* 3.3.3: Better position locating +* 3.3.1: Update jquery +* 3.3.0: Position problem in chrome +* 3.2.9: Update to jquery v3 +* 3.2.8: Fix multi tabs +* 3.2.7: Update to jQuery 3.1.0 +* 3.2.6: Auto copying in chrome +* 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 +* 3.1.3: Background mode +* 3.1.2: Fix translation +* 3.1.0: Iframe support +* 3.0.5: TaoBao fix +* 3.0.4: Mouseup event +* 3.0.3: Css fix +* 3.0.2: New setting box +* 3.0.0: UI redesigned +* 2.9.7: Google Page +* 2.9.5: Setting window +* 2.9.1: In site search fix up +* 2.9.0: In site search added +* 2.8.5: Translate sync +* 2.8.4: Cleanup +* 2.8.2: Better css style +* 2.8.1: Multiply translate address +* 2.8.0: More translation methods +* 2.7.5: Exclude test pages +* 2.7.4: Fix up +* 2.7.3: UI improvement +* 2.7.2: Update method change +* 2.7.1: Meta info added +* 2.7.0: Switch to git +* 2.6.8: New setting window +* 2.6.7: New style code +* 2.6.6: Clean up codes +* 2.6.5: Update translation +* 2.6.4: Improve css style +* 2.6.3: Rewritten translation part. +* 2.6.2: Add failsafe translation +* 2.6.1: Fix Popup size +* 2.6.0: Update Jquery ## Text to Link -* 2.8.4 : Complier by coffeescript 2 -* 2.8.3 : Exclude ali pay. -* 2.8.1 : Recognize prefix correctly. -* 2.8.0 : Support timeout -* 2.7.2 : Update icon and links -* 2.7.0 : Exclude 163.com -* 2.6.9 : exclude rule -* 2.6.8 : exclude *www.google.* -* 2.6.7 : Fix for ZhiHu -* 2.6.5 : Meta update -* 2.6.4 : Ext tag -* 2.6.3 : '/' as end char -* 2.6.1 : observer -* 2.5.1 : Fix -* 2.5.0 : 修复了一个低级错误导致的http前缀重复... -* 2.4.4 : 分段加载提高效率 -* 2.4.3 : Fix RegExp -* 2.4.2 : New Mode to replace link, better performance -* 2.4.1 : Update regexp, "use strict" mode to enhance performance -* 2.4.0 : Fix scan error on ending chapter -* 2.3.9 : 更新meta内容 -* 2.3.8 : 迁移到 greasyfork -* 2.3.7 : 更新正则表达式 -* 2.3.6 : 更新正则表达式 -* 2.3.5 : 恢复对微博的支持 -* 2.3.4 : 修复偶尔不能识别https的问题 -* 2.3.3 : 排除微博 -* 2.3.2 : Bug fix -* 2.3.1 : Bug fix -* 2.3.0 : 大幅修改了选择器代码 -* 2.2.5 : 排除code标签 -* 2.2.4 : 新增部分域名后缀 -* 2.2.3 : 优化正则表达式 -* 2.2.2 : 修复因为延迟可能错过某些链接的问题 -* 2.2.1 : 修正正则表达式 -* 2.2.0 : 改用CoffeeScript生成 -* 2.1.4 : 修复识别错误 -* 2.1.3 : Little Fix -* 2.1.2 : 混合分析以提高效率 -* 2.1.1 : 改变延迟参数 -* 2.1.0 : 彻底重写了代码... 应该几乎不会有什么卡顿了 -* 2.0.9 : 降低卡顿 -* 2.0.8 : 修复bug -* 2.0.7 : 优化正则表达式 -* 2.0.6 : 提高执行效率 -* 2.0.5 : 修复中文识别 -* 2.0.4 : 修复自动翻页 +* 2.8.4: Complier by coffeescript 2 +* 2.8.3: Exclude ali pay. +* 2.8.1: Recognize prefix correctly. +* 2.8.0: Support timeout +* 2.7.2: Update icon and links +* 2.7.0: Exclude 163.com +* 2.6.9: exclude rule +* 2.6.8: exclude *www.google.* +* 2.6.7: Fix for ZhiHu +* 2.6.5: Meta update +* 2.6.4: Ext tag +* 2.6.3: '/' as end char +* 2.6.1: observer +* 2.5.1: Fix +* 2.5.0: 修复了一个低级错误导致的http前缀重复... +* 2.4.4: 分段加载提高效率 +* 2.4.3: Fix RegExp +* 2.4.2: New Mode to replace link, better performance +* 2.4.1: Update regexp, "use strict" mode to enhance performance +* 2.4.0: Fix scan error on ending chapter +* 2.3.9: 更新meta内容 +* 2.3.8: 迁移到 greasyfork +* 2.3.7: 更新正则表达式 +* 2.3.6: 更新正则表达式 +* 2.3.5: 恢复对微博的支持 +* 2.3.4: 修复偶尔不能识别https的问题 +* 2.3.3: 排除微博 +* 2.3.2: Bug fix +* 2.3.1: Bug fix +* 2.3.0: 大幅修改了选择器代码 +* 2.2.5: 排除code标签 +* 2.2.4: 新增部分域名后缀 +* 2.2.3: 优化正则表达式 +* 2.2.2: 修复因为延迟可能错过某些链接的问题 +* 2.2.1: 修正正则表达式 +* 2.2.0: 改用CoffeeScript生成 +* 2.1.4: 修复识别错误 +* 2.1.3: Little Fix +* 2.1.2: 混合分析以提高效率 +* 2.1.1: 改变延迟参数 +* 2.1.0: 彻底重写了代码... 应该几乎不会有什么卡顿了 +* 2.0.9: 降低卡顿 +* 2.0.8: 修复bug +* 2.0.7: 优化正则表达式 +* 2.0.6: 提高执行效率 +* 2.0.5: 修复中文识别 +* 2.0.4: 修复自动翻页 ## Tieba Enhance -* 6.2.1 : Complier by coffeescript 2 -* 6.2.0 : Add tail correctly -* 6.1.5 : Update icon and jquery -* 6.1.1 : Random Tail -* 6.1.0 : Fixed all known issues -* 6.0.5 : Soft checking -* 6.0.3 : Code merge -* 6.0.2 : Cleanup -* 6.0.1 : Update for date checking -* 6.0.0 : Remove recent ico -* 5.9.7 : Fix eval -* 5.9.5 : Fix tail trigger -* 5.9.5 : fix tail box may not shown -* 5.9.4 : Html code cleanup -* 5.9.3 : Fix for new navtab -* 5.9.2 : clearLink fix -* 5.9.0 : New backend -* 5.8.7 : fix up -* 5.8.6 : coffee script -* 5.8.5 : Fix recent img -* 5.8.4 : Fix jquery -* 5.8.2 : Clear tieba link function -* 5.8.1 : Minify storage -* 5.8.0 : Switch to git -* 5.7.8 : Update to suite new tieba -* 5.7.7 : Meta info added -* 5.7.6 : 修复样式 -* 5.7.5 : Clear Link -* 5.7.4 : 新的提醒样式 -* 5.7.3 : 时间兼容处理延迟 -* 5.7.2 : 新版的时间兼容处理 -* 5.7.1 : 新版的时间处理 -* 5.7.0 : little fix +* 6.2.1: Complier by coffeescript 2 +* 6.2.0: Add tail correctly +* 6.1.5: Update icon and jquery +* 6.1.1: Random Tail +* 6.1.0: Fixed all known issues +* 6.0.5: Soft checking +* 6.0.3: Code merge +* 6.0.2: Cleanup +* 6.0.1: Update for date checking +* 6.0.0: Remove recent ico +* 5.9.7: Fix eval +* 5.9.5: Fix tail trigger +* 5.9.5: fix tail box may not shown +* 5.9.4: Html code cleanup +* 5.9.3: Fix for new navtab +* 5.9.2: clearLink fix +* 5.9.0: New backend +* 5.8.7: fix up +* 5.8.6: coffee script +* 5.8.5: Fix recent img +* 5.8.4: Fix jquery +* 5.8.2: Clear tieba link function +* 5.8.1: Minify storage +* 5.8.0: Switch to git +* 5.7.8: Update to suite new tieba +* 5.7.7: Meta info added +* 5.7.6: 修复样式 +* 5.7.5: Clear Link +* 5.7.4: 新的提醒样式 +* 5.7.3: 时间兼容处理延迟 +* 5.7.2: 新版的时间兼容处理 +* 5.7.1: 新版的时间处理 +* 5.7.0: little fix diff --git a/README.md b/README.md index 4e0cce0..6f017dc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## 安装链接 / Install links -点击下面的链接安装GM脚本 / Click links bellow to install +点击下面的链接安装GM脚本 / Click links below to install * [Popup Search](https://git.oschina.net/coldfire/GM/raw/master/popsearch.user.js) * [Text to link](https://git.oschina.net/coldfire/GM/raw/master/linkMix.user.js) @@ -30,7 +30,7 @@ Popup search/translate(etc) button for selected texts ![Function](http://lkytal.qiniudn.com/t.png) -GM的"用户脚本设置"下的"Popup Search设置"打开选项选择需要的项目 +GM 的"用户脚本设置"下的"Popup Search设置"打开选项选择需要的项目 ![Set](http://lkytal.qiniudn.com/pset1.png) ![Set](http://lkytal.qiniudn.com/pset2.png) @@ -43,11 +43,11 @@ GM的"用户脚本设置"下的"Popup Search设置"打开选项选择需要的 1. 不会把相连的中文错误识别为链接的一部分 1. 支持AutoPage, SuperPreload等 -注意 : 为了提高执行速度, 去除了对邮箱地址和ftp链接的识别 +注意: 为了提高执行速度, 去除了对邮箱地址和ftp链接的识别 #### Advances -1. Support links that does not start with “http” +1. Support links that do not start with “http” 1. Support AutoPage, SuperPreload (etc) 1. Support Unicode characters diff --git a/meta/popsearch.meta.js b/meta/popsearch.meta.js index 5a65fa1..984a8c4 100644 --- a/meta/popsearch.meta.js +++ b/meta/popsearch.meta.js @@ -11,7 +11,7 @@ // @exclude http://www.sf-express.com/* // @exclude http://furk.net/* // @require https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js -// @version 4.2.3 +// @version 4.2.4 // @icon http://lkytal.qiniudn.com/search.png // @grant GM_xmlhttpRequest // @grant GM_addStyle @@ -21,6 +21,7 @@ // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand +// @grant GM_info // @charset UTF-8 // @homepageURL https://git.oschina.net/coldfire/GM // @updateURL https://git.oschina.net/coldfire/GM/raw/master/meta/popsearch.meta.js diff --git a/popsearch.user.js b/popsearch.user.js index 2f75a23..2788b46 100644 --- a/popsearch.user.js +++ b/popsearch.user.js @@ -11,7 +11,7 @@ // @exclude http://www.sf-express.com/* // @exclude http://furk.net/* // @require https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js -// @version 4.2.3 +// @version 4.2.4 // @icon http://lkytal.qiniudn.com/search.png // @grant GM_xmlhttpRequest // @grant GM_addStyle @@ -21,6 +21,7 @@ // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand +// @grant GM_info // @charset UTF-8 // @homepageURL https://git.oschina.net/coldfire/GM // @updateURL https://git.oschina.net/coldfire/GM/raw/master/meta/popsearch.meta.js @@ -95,10 +96,6 @@ popData = { id: "Fade_st", text: "超时自动隐藏 / Hide after timeout", defaultValue: 1 - }, { - id: "Dis_st", - text: "显示于文字上方 / Display above selection", - defaultValue: 1 }, { id: "Tab_st", text: "新标签页打开 / Open in new tabs", @@ -107,6 +104,10 @@ popData = { id: "Focus_st", text: "前台标签页打开 / Force foreground tabs", defaultValue: 1 + }, { + id: "Trans_st", + text: "显示翻译按钮 / Display translate button", + defaultValue: 1 }, { id: "Iframe_st", text: "在Iframe中显示/ Load in iframes", @@ -115,6 +116,10 @@ popData = { id: "Copy_st", text: "自动复制选中文字 / Auto copy selections", defaultValue: 0 + }, { + id: "Dis_st", + text: "显示于文字上方 / Display above selection", + defaultValue: 1 }, { id: "Ctrl_st", text: "仅按下Ctrl时显示 / Only when ctrl pressed", @@ -369,8 +374,11 @@ PopupInit = function () { $icon.hide(); } } - $('#ShowUpBox').find('.engine, .userEngine').on('click', OnEngine); + $DivBox.find('.engine, .userEngine').on('click', OnEngine); $('#transBtn').on("click", onTranslate); + if (!GetOpt('Trans_st')) { + $('#transBtn').hide(); + } if (GetOpt('Tab_st')) { $DivBox.find('a').attr('target', '_blank'); } else { @@ -468,7 +476,7 @@ $(document).on("mousedown", function (event) { if (popData.bTrans === 1) { PopupInit(); } - return $('#ShowUpBox').hide(); + return $('#ShowUpBox').fadeOut(200); }); $(document).on("mouseup", function (event) { @@ -517,7 +525,7 @@ ShowBar = function (event) { return; } popData.rawText = sel.toString(); - popData.text = encodeURIComponent(popData.rawText); + popData.text = encodeURIComponent(popData.rawText.trim()); if (popData.rawText === '') { return; } @@ -554,14 +562,14 @@ ShowBar = function (event) { setHref(engine); } if (needPrefix(popData.rawText)) { - $('#Open_stIcon').data('link', "http://" + popData.rawText); + $('#Open_stIcon').data('link', "http://" + popData.rawText.trim()); } popData.mouseIn = 0; popData.bTrans = 0; clearTimeout(popData.timer); popData.timer = setTimeout(TimeOutHide, 6000); fixPos(sel, event); - return $('#ShowUpBox').css('opacity', 0.9).fadeIn(150); + return $('#ShowUpBox').css('opacity', 0.9).fadeIn(200); }; needPrefix = function (url) { @@ -580,16 +588,21 @@ CopyText = function (selText) { if (selText == null) { selText = document.defaultView.getSelection().toString(); } + if (GM_info.scriptHandler === "Violentmonkey") { + return document.execCommand('copy'); + } try { return GM_setClipboard(selText, "text"); } catch (error) { - alert("ERROR: Auto copy not supported and will be disabled now"); - return SaveOpt("Copy_st", 0); + return document.execCommand('copy'); } }; GetOpt = function (id) { - return GM_getValue(id); + var ref; + return GM_getValue(id, (ref = popData.optionList.find(function (item) { + return item.id === id; + })) != null ? ref.defaultValue : void 0); }; SaveOpt = function (id) { @@ -597,7 +610,7 @@ SaveOpt = function (id) { }; ReadOpt = function (id) { - return $("#" + id + " > input").prop("checked", GM_getValue(id)); + return $("#" + id + " > input").prop("checked", GetOpt(id)); }; OpenSet = function () { @@ -638,8 +651,8 @@ SettingWin = function () { return results; }().join(' '); engJSON = '[\n {\n id: "UserEngine",\n title: "Example Engine",\n description: "Example of user-defined engine",\n src: "http://lkytal.qiniudn.com/ic.ico",\n href: "https://www.google.com/search?q=${text}"\n }\n]'; - chsJSON = '[\n {\n id: "UserEngine",\n title: "Example Engine",\n description: "自定义引擎实例",\n src: "http://lkytal.qiniudn.com/ic.ico",\n href: "https://www.google.com/search?q=${text}"\n }\n]'; - $("body").append("
You can redistribute it under Creative Commons Attribution-NonCommercial-ShareAlike Licence
Source Code at
Git OSChina https://git.oschina.net/coldfire/GM
Github https://github.com/lkytal/GM
Contact:
Github https://github.com/lkytal/
Greasy fork https://greasyfork.org/en/users/152-lkytal
" + engJSON + "The 'id' should be unique for every entry and must NOT contain any space character , the 'title' and the 'description' can be any text you like, the 'src' indicates the icon of every item, should be the url to an image or be a DataURL. The 'href' is the link to be open upon click, you may have noticed the '${text}' variable, which will be replaced by selected text. Available variables are listed bellow:
" + chsJSON + "\u6BCF\u4E00\u9879\u7684 id \u5FC5\u987B\u5404\u4E0D\u76F8\u540C\u4E14\u4E0D\u80FD\u542B\u6709\u7A7A\u683C, title \u548C description \u53EF\u4EE5\u968F\u610F\u586B\u5199, src \u662F\u8BE5\u9879\u7684\u56FE\u6807, \u53EF\u4EE5\u662F\u6307\u5411\u56FE\u6807\u7684 url \u6216\u8005\u662F\u4E00\u4E2A DataURL. href \u662F\u5F15\u64CE\u7684 url \u94FE\u63A5, \u5176\u4E2D\u53EF\u4EE5\u5305\u542B\u8BF8\u5982 ${text} \u8FD9\u6837\u7684\u53D8\u91CF, \u53D8\u91CF\u7684\u5927\u5C0F\u5199\u5FC5\u987B\u6B63\u786E, \u53EF\u7528\u7684\u53D8\u91CF\u6709:
You can redistribute it under Creative Commons Attribution-NonCommercial-ShareAlike Licence
Source Code at
Git OSChina https://git.oschina.net/coldfire/GM
Github https://github.com/lkytal/GM
Contact:
Github https://github.com/lkytal/
Greasy fork https://greasyfork.org/en/users/152-lkytal
" + engJSON + "The 'id' should be unique for every entry and must NOT contain any space character, the 'title' and the 'description' can be any text you like, the 'src' indicates the icon of every item, should be the URL to an image or be a DataURL. The 'href' is the link to be open upon click, you may have noticed the '${text}' variable, which will be replaced by selected text. Available variables are listed below:
" + chsJSON + "\u6BCF\u4E00\u9879\u7684 id \u5FC5\u987B\u5404\u4E0D\u76F8\u540C\u4E14\u4E0D\u80FD\u542B\u6709\u7A7A\u683C, title \u548C description \u53EF\u4EE5\u968F\u610F\u586B\u5199, src \u662F\u8BE5\u9879\u7684\u56FE\u6807, \u53EF\u4EE5\u662F\u6307\u5411\u56FE\u6807\u7684 url \u6216\u8005\u662F\u4E00\u4E2A DataURL. href \u662F\u5F15\u64CE\u7684 url \u94FE\u63A5, \u5176\u4E2D\u53EF\u4EE5\u5305\u542B\u8BF8\u5982 ${text} \u8FD9\u6837\u7684\u53D8\u91CF, \u53D8\u91CF\u7684\u5927\u5C0F\u5199\u5FC5\u987B\u6B63\u786E, \u53EF\u7528\u7684\u53D8\u91CF\u6709:
自定义引擎功能开放, 点击 'Open setting' 可以打开设置并启用该功能. 在自定义前请点击 'Help' 按钮以阅读帮助文档.
注意: 启用自定义引擎后, 重新打开设置窗口才会生效.
You can customize your own engines now. Click 'Open setting' to check it out. Remember to read 'HELP' before edit.
Note: After you enabled customization, reopen setting window to take effect.
自定义引擎功能开放, 点击 'Open setting' 可以打开设置并启用该功能. 在自定义前请点击 'Help' 按钮以阅读帮助文档.
注意: 启用自定义引擎后, 重新打开设置窗口才会生效.
You can customize your own engines now. Click 'Open setting' to check it out. Remember to read 'HELP' before modify.
Note: After you enabled customization, reopen setting window to take effect.