Skip to content

Commit

Permalink
change copyright js
Browse files Browse the repository at this point in the history
  • Loading branch information
morizunzhu committed Feb 15, 2020
1 parent 0bfdc15 commit 3357be9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
10 changes: 7 additions & 3 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public static function footer()
//星星鼠标轨迹
$mouseStar = $options->pluginUrl . '/SkyMo/js/mouse/star/canvas.js';
echo "<script src='$mouseStar'></script>";

//版权相关
$copyright = $options->pluginUrl . '/SkyMo/js/copyright.js';
echo "<script src='$copyright'></script>";


}

/**
Expand All @@ -116,7 +122,5 @@ public static function header()

$src = $options->pluginUrl . '/SkyMo/js/header.js';
echo "<script src='$src'></script>";
$copyright = $options->pluginUrl . '/SkyMo/js/copyright.js';
echo "<script src='$copyright'></script>";
}
}
}
31 changes: 20 additions & 11 deletions js/copyright.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
document.addEventListener('copy', function (e) {
/* ***
*
* By: Morizunzhu
* Last Update: 2020.1.14
*** */
document.body.addEventListener('copy', function (e) {
if (window.getSelection().toString() && window.getSelection().toString().length > 42) {
setClipboardText(e);
// alert('商业转载请联系作者获得授权,非商业转载请注明出处哦~\n谢谢合作~(。・`ω´・)');
Expand All @@ -8,22 +15,24 @@ function setClipboardText(event) {
var clipboardData = event.clipboardData || window.clipboardData;
if (clipboardData) {
event.preventDefault();
var author = "就当一次路过丶"//"<?php $this->author() ?>";
var url = "http://www.cloudmo.top";//"<?php $this->options->siteUrl(); ?>";
var htmlData = ''
+ window.getSelection().toString()
+ '著作权归作者所有。<br>'
+ '商业转载请联系作者获得授权,非商业转载请注明出处。<br>'
+ '作者:<?php $this->author() ?><br>'
+ '链接:' + window.location.href + '<br>'
+ '来源:<?php $this->options->siteUrl(); ?><br><br>'
+ window.getSelection().toString();
+ '作者:' + author + '<br>'
+ '链接:' + window.location.href + '<br>';

var textData = ''
+ window.getSelection().toString()
+ '著作权归作者所有。\n'
+ '商业转载请联系作者获得授权,非商业转载请注明出处。\n'
+ '作者:<?php $this->author() ?>\n'
+ '链接:' + window.location.href + '\n'
+ '来源:<?php $this->options->siteUrl(); ?>\n\n'
+ window.getSelection().toString();

+ '作者:' + author + '\n'
+ '链接:' + window.location.href + '\n';
console.log(textData);
clipboardData.setData('text/html', htmlData);
clipboardData.setData('text/plain', textData);
}
}
}

0 comments on commit 3357be9

Please sign in to comment.