复制提醒、禁用F12、禁用Ctrl+S等

WordPress添加复制提醒、WordPress添加复制提醒、禁用F12、禁用Ctrl+S、禁用Ctrl+U、禁用Ctrl+Shift+I、右键菜单提醒、禁用Ctrl+Shift+I、右键菜单提醒!

效果演示

nocopy

这个弹窗个人觉得很好看,一般只有“复制提醒(附带复制失败提醒)”、“禁用F12”、“禁用鼠标右键”,狐狸库这里把常见的“禁用Ctrl+U”、“禁用Ctrl+S”、“禁用Ctrl+Shift+I”等都分享给大家。

代码路径

/wp-content/themes/zibll/header.php 加入以下引入代码

<!-- 引入VUE -->
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
<!-- 引入样式 -->
<script src="https://unpkg.com/[email protected]/lib/index.js"></script>
<!-- 引入组件库 -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/packages/theme-chalk/lib/index.css">

全部代码

Zibll主题设置 >> 全局&功能 >> 自定义代码 >> 自定义javascript代码 里面加入以下代码

根据你的需要选取部分或全部代码使用!

//复制Ctrl+C提醒
/*Copy Remind*/
document.addEventListener("copy", function(e) {
  new Vue({
    data: function() {
            if((window.getSelection ? window.getSelection() : document.selection.createRange().text) != ''){
          this.$notify({
            title: "叮!复制成功",
            message: "若要转载请务必保留原文链接!谢谢~",
            position: 'bottom-right',
            offset: 50,
            showClose: true,
            type: "success"
          });
            }else{
          this.$notify({
            title: "咦?复制失败",
            message: "啊噢...你没还没选择内容呢!",
            position: 'bottom-right',
            offset: 50,
            showClose: true,
            type: "success"
          });
            }
      return {
        visible: false
      }
    }
  })
})

//禁用鼠标右键菜单提醒
/*Right click prohibited*/
document.oncontextmenu = function () {
new Vue({
    data:function(){
        this.$notify({
            title:"嘿!没有右键<a target="_blank" href="https://chenyu.me" title="View all posts in 菜单">菜单</a>",
            message:"复制请用键盘<a target="_blank" href="https://chenyu.me" title="View all posts in 快捷">快捷</a>键[Ctrl+C]",
            position: 'bottom-right',
            offset: 50,
            showClose: false,
            type:"warning"
        });
        return{visible:false}
    }
})
return false;
}

//禁用F12按键提醒(开发者工具快捷键)
/*Prohibit F12*/
document.onkeydown = function () {
if (window.event && window.event.keyCode == 123) {
  event.keyCode = 0;
  event.returnValue = false;
    new Vue({
            data:function(){
                this.$notify({
                    title:"嘿!别瞎按",
                    message:"你按这个想干嘛!",
                    position: 'bottom-right',
                    offset: 50,
                    showClose: false,
                    type:"error"
                });
                return{visible:false}
            }
        })
  return false;
}

//禁用Ctrl+Shift+I(开发者工具快捷键)
/*Prohibit Ctrl+Shift+I*/
if ((event.ctrlKey) && (event.shiftKey) && (event.keyCode == 73)) {
event.keyCode = 0;
  event.returnValue = false;
    new Vue({
            data:function(){
                this.$notify({
                    title:"嘿!这个也不行",
                    message:"还是按点别的吧!",
                    position: 'bottom-right',
                    offset: 50,
                    showClose: false,
                    type:"error"
                });
                return{visible:false}
            }
        })
         return false;
}};

//禁用Ctrl+S(保存网页/文件)
/*Prohibit 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+U(查看网页源代码)
/*Prohibit Ctrl+U*/
  if (event.ctrlKey && window.event.keyCode == 85) {
    new Vue({
      data: function() {
        this.$notify({
          title: "嘿!Brother",
          message: "老弟,<a target="_blank" href="https://huliku.com/tag/%e6%ba%90%e7%a0%81" title="View all posts in 源码">源码</a>得换方式获取哦~",
          position: 'bottom-right',
          offset: 50,
          showClose: true,
          type: "error"
        });
        return {
          visible: false
        }
      }
    })
    return false;
  }

//禁用左键选择
      document.onselectstart = function () {
        return false;
      }
© 版权声明
THE END
如果喜欢,可以【点赞】【分享】【收藏】
点赞8赞赏 分享
评论 抢沙发
头像
人生坎坎,山山而峦,不过尔尔;心路漫漫,水水而川,如此悠悠
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容