Giter Club home page Giter Club logo

pageguard.js's Introduction

PageGuard.js

No copying, printing as well as opening developers tools.

It can prevents user from :

  • Select
  • Print
  • Right click
  • Crtl / Shift / Alt / F12
  • Open Developers Tools (Including opening in a separate window)

You can use CSS if you don't run Javascript. But for safety, you should use this javascript and make your page only show when the Javscript is on.

Uasge

Download or

<script type="text/javascript" src="https://netrvin.github.io/PageGuard.js/pageguard.min.js"></script>

AntiCopy

var anticopy_id = PageGuard.anticopy();

You can use the following codes to allow user to copy again (Cannot clear the CSS):

clearInterval(anticopy_id);
document.oncontextmenu = null; 
document.oncopy = null;
document.onselectstart = null;
document.ondragstart = null;
document.oncopy = null;
document.onbeforecopy = null;
document.onkeydown = null;
window.onhelp = null;

Detect Developers Tools

Supported:

  • Chrome (latest version : 66)
  • Opera (latest version : 52)
  • Firefox (latest version : 59) (If it opens in a separate window, it will only work when the user open the console)
  • Others (Not tested)

It can only run one at the same time.

var detect_key = PageGuard.detectDevTools(function () {
	// Your codes will run when developers tools is opening
});

You can also use the following codes to stop detecting:

PageGuard.stopDetecting(detect_key);

Safe Tips

Don't let user get the anticopy_id and the detect_key. You can write your codes like this:

(function () {
    // codes
})();

Addons

Anti Copy & Print (CSS)

Download or

<link href="https://netrvin.github.io/PageGuard.js/anticopy.min.css" rel="stylesheet">

Examples

https://netrvin.github.io/PageGuard.js/example.html

Thanks

https://github.com/sindresorhus/devtools-detect

https://stackoverflow.com/questions/7798748/find-out-whether-chrome-console-is-open

pageguard.js's People

Contributors

netrvin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.