Skip to content

Commit

Permalink
popup copy
Browse files Browse the repository at this point in the history
  • Loading branch information
lkytal committed Feb 27, 2018
1 parent 130a650 commit c686dc9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 29 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ All notable changes to all the scripts will be documented in this file.

## Popup Search

* 4.3.0: Provide 'Copy' button.
* 4.2.7: Https icons.
* 4.2.6: Update Jquery
* 4.2.6: 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`.
Expand Down
16 changes: 8 additions & 8 deletions linkMix.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @description:zh 把文字链接转换为可点击链接
// @author lkytal
// @namespace Lkytal
// @version 2.8.5
// @version 2.8.6
// @homepage https://lkytal.github.io/
// @homepageURL https://lkytal.github.io/coldfire/GM
// @license AGPL
Expand Down Expand Up @@ -38,9 +38,9 @@ url_regexp = /((https?:\/\/|www\.)[\x21-\x7e]+[\w\/]|(\w[\w._-]+\.(com|cn|org|ne
urlPrefixes = ['http://', 'https://', 'ftp://', 'thunder://', 'ed2k://'];

clearLink = function (event) {
var j, len, link, prefix, ref, url;
var j, len, link, prefix, ref, ref1, url;
link = (ref = event.originalTarget) != null ? ref : event.target;
if (!(link != null && link.localName === "a" && link.className.indexOf("textToLink") !== -1)) {
if (!(link != null && link.localName === "a" && ((ref1 = link.className) != null ? ref1.indexOf("textToLink") : void 0) !== -1)) {
return;
}
url = link.getAttribute("href");
Expand All @@ -57,12 +57,12 @@ clearLink = function (event) {
document.addEventListener("mouseover", clearLink);

setLink = function (candidate) {
var span, text;
if (candidate == null || candidate.parentNode.className.indexOf("textToLink") !== -1 || candidate.nodeName === "#cdata-section") {
var ref, ref1, ref2, span, text;
if (candidate == null || ((ref = candidate.parentNode) != null ? (ref1 = ref.className) != null ? typeof ref1.indexOf === "function" ? ref1.indexOf("textToLink") : void 0 : void 0 : void 0) !== -1 || candidate.nodeName === "#cdata-section") {
return;
}
text = candidate.textContent.replace(url_regexp, '<a href="$1" target="_blank" class="textToLink">$1</a>');
if (candidate.textContent.length === text.length) {
if (((ref2 = candidate.textContent) != null ? ref2.length : void 0) === text.length) {
return;
}
span = document.createElement("span");
Expand All @@ -78,15 +78,15 @@ linkPack = function (result, start) {
var i, j, k, ref, ref1, ref2, ref3, startTime;
startTime = Date.now();
while (start + 10000 < result.snapshotLength) {
for (i = j = ref = start, ref1 = start + 10000; undefined !== 0 && (ref <= ref1 ? ref <= j && j <= ref1 : ref >= j && j >= ref1); i = ref <= ref1 ? ++j : --j) {
for (i = j = ref = start, ref1 = start + 10000; ref <= ref1 ? j <= ref1 : j >= ref1; i = ref <= ref1 ? ++j : --j) {
setLink(result.snapshotItem(i));
}
start += 10000;
if (Date.now() - startTime > 2500) {
return;
}
}
for (i = k = ref2 = start, ref3 = result.snapshotLength; undefined !== 0 && (ref2 <= ref3 ? ref2 <= k && k <= ref3 : ref2 >= k && k >= ref3); i = ref2 <= ref3 ? ++k : --k) {
for (i = k = ref2 = start, ref3 = result.snapshotLength; ref2 <= ref3 ? k <= ref3 : k >= ref3; i = ref2 <= ref3 ? ++k : --k) {
setLink(result.snapshotItem(i));
}
};
Expand Down
4 changes: 2 additions & 2 deletions meta/linkMix.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// @description:zh 把文字链接转换为可点击链接
// @author lkytal
// @namespace Lkytal
// @version 2.8.5
// @version 2.8.6
// @homepage https://lkytal.github.io/
// @homepageURL https://lkytal.github.io/coldfire/GM
// @license LGPL
// @license AGPL
// @include *
// @exclude *pan.baidu.com/*
// @exclude *renren.com/*
Expand Down
4 changes: 2 additions & 2 deletions meta/popsearch.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// @name Popup Search
// @author lkytal
// @namespace Lkytal
// @version 4.2.7
// @version 4.3.0
// @icon https://github.com/lkytal/GM/raw/master/icons/search.png
// @homepage https://lkytal.github.io/
// @homepageURL https://lkytal.github.io/
// @description Popup search box and translate button (etc) for selected texts
// @description:zh 为选中文字弹出搜索和翻译的快捷按钮
// @license LGPL
// @license AGPL
// @include *
// @exclude */test/*.html*
// @exclude http://acid3.acidtests.org/*
Expand Down
2 changes: 1 addition & 1 deletion meta/tieba_enhance.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// @require https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js
// @icon https://github.com/lkytal/GM/raw/master/icons/tieba.png
// @noframes
// @license LGPL
// @license AGPL
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
Expand Down
Loading

0 comments on commit c686dc9

Please sign in to comment.