pure JavaScript version of copyright
npm i -S pure-copyright
import Copyright from 'pure-copyright'
or
<script src="https://unpkg.com/pure-copyright@latest"></script>
new Copyright(document.body)
You can pass an options object in plugin init method.
text
: The text that will be added when copying (Default:"<br>Original: " + window.location.href
);minlength
: The minimum length of the copied text when running the plugin (Default:0
).processing
: Function to process the copied text (Default:undefined
).
new Copyright(document.body, {
text: "<br><br>Reference: " + window.location.href,
minlength: 100,
processing: function(text) {
console.log(text)
}
})
- destory:Stop the plugin
You can listen Copyright events.
beforeCopy
afterCopy
new Copyright(document.body, {
processing: function (text) {
console.log(text)
}
}).on('beforeCopy', () => {
console.log(+ new Date())
}).on('afterCopy', () => {
console.log(+ new Date())
})
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
pure-copyright © sinchang, Released under the MIT License.
Authored and maintained by sinchang with help from contributors (list).
sinchang.me · GitHub @sinchang · Twitter @sinchangwen