WordPress主题 禁止用户获取代码教程-子比可用

之前网站分享了如何禁止右键,今天来分享一下WordPress如何禁止用户以各种方式获取代码,其实跟禁止邮件类似,禁止用户操作以获取相关信息,比如禁止复制,禁止右键等,这个对弹出的对话框尽心了美化,个人还是比较喜欢的,只要是WordPress都可以使用,子比,7B2啥的都可以使用,放在合适的位置即可。

WordPress主题 禁止用户获取代码教程-子比可用

使用方法

引用CSS,把以下代码添加到子比的主题设置-自定义代码里的自定义底部HTML代码里即可。

<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.6/lib/index.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.6/packages/theme-chalk/lib/index.css" rel="external nofollow" >

把以下代码添加到子比的主题设置-自定义代码里的自定义javascript代码里即可。

站长已亲测贴心的标上了注释。

//禁止用户以各种方式获取代码
/*ctrl+u*/
document.onkeydown=function(){if(event.ctrlKey&&window.event.keyCode==85){new Vue({data:function(){this.$notify({title:"嘿!别瞎按",message:"老弟,想偷我源码?~",position:'bottom-right',offset:50,showClose:true,type:"error"});return{visible:false}}})
return false;}
/*f 12*/
if(window.event&&window.event.keyCode==123){event.keyCode=0;event.returnValue=false;new Vue({data:function(){this.$notify({title:"嘿!Bingo~",message:"老弟,试试 Alt+Shift+Fn+F4",position:'bottom-right',offset:50,showClose:true,type:"error"});return{visible:false}}})
return false;}
/*ctrl+s*/
if(event.ctrlKey&&window.event.keyCode==83){new Vue({data:function(){this.$notify({title:"嘿!你瞧瞧你",message:"网页得换方法保存哦~",position:'bottom-right',offset:50,showClose:true,type:"error"});return{visible:false}}})
return false;}
/*ctrl+shift+i*/
if((event.ctrlKey)&&(event.shiftKey)&&(event.keyCode==73)){new Vue({data:function(){this.$notify({title:"嘿!哈哈哈",message:"老弟,调试方法也得换换哟~",position:'bottom-right',offset:50,showClose:true,type:"error"});return{visible:false}}})
return false;}
/*f5*/
if(window.event&&window.event.keyCode==116){event.keyCode=0;event.returnValue=false;new Vue({data:function(){this.$notify({title:"嘿!喂喂喂",message:"浏览器自带刷新按钮不香吗?",position:'bottom-right',offset:50,showClose:true,type:"warning"});return{visible:false}}})
return false;}}
/*复制tips*/
document.addEventListener("copy",function(e){new Vue({data:function(){this.$notify({title:"叮!复制成功",message:"若要转载必须保留本站原文链接!",position:'bottom-right',offset:50,showClose:true,type:"success"});return{visible:false}}})})
/* 禁用右键菜单并提醒 */
document.oncontextmenu = function (){new Vue({data:function(){this.$notify({title:"嘿!没有右键菜单",message:"复制请用键盘快捷键 Ctrl+C",position:'bottom-right',offset:50,showClose:true,type:"warning"});return{visible:false}}})
return false;}
THE END
抢沙发
头像
提交
头像

昵称

取消
昵称

    暂无评论内容