pure-copyright

0.0.2 • Public • Published

pure-copyright

NPM version NPM downloads

pure JavaScript version of copyright

Install

npm i -S pure-copyright

Usage

import Copyright from 'pure-copyright'
 
or
 
<script src="https://unpkg.com/pure-copyright@latest"></script>
 
new Copyright(document.body)

Options

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)
  }
})

Methods:

  • destory:Stop the plugin

Events:

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())
})

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

Author

pure-copyright © sinchang, Released under the MIT License.
Authored and maintained by sinchang with help from contributors (list).

sinchang.me · GitHub @sinchang · Twitter @sinchangwen

Readme

Keywords

none

Package Sidebar

Install

npm i pure-copyright

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • sinchang