惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
L
LangChain Blog
博客园 - 司徒正美
G
Google Developers Blog
博客园 - 【当耐特】
GbyAI
GbyAI
月光博客
月光博客
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
D
Docker
MongoDB | Blog
MongoDB | Blog
Vercel News
Vercel News
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
博客园 - 聂微东

韩小韩博客

你还在用真实邮箱注册网站?等等,你真的想清楚了吗? IPFS星际文件系统 最新二合一收款码 - 物理合并版 从Hexo到Astro博客1分钟迁移指南 Astro 添加 Waline 评论组件 腾讯云 EdgeOne Pages 实测对比:能否成为国内开发者的 Cloudflare Pages 最佳平替? Astro 中使用 Lenis 增加鼠标滚动阻尼感 一组手机和电脑动态壁纸分享【分享】 Astro 添加 Twikoo 评论组件 Astro主题-优雅的vhAstro-Theme【使用文档】 Fetch的GET、POST简单HTTP请求封装 一些实拍的手机壁纸 大理And威海【图】 很喜欢西湖的水【转自:狮子狮子鱼】 Tarot-塔罗牌占卜 Web Watermark 图片添加水印在线小助手 HanAnalytics访问分析Web统计托管于(Cloudflare Pages) 基于AI的微博动态心情分析 阿里云免费用9年ecs教程【适合轻量化服务如frp】 Cloudflare优选IP➕DnsPod的DDNS自动切换 混沌神器Clash全家桶 卷王都在用的变态休息法 NodeJs文本相似度去重脚本 骤雨重山无限存储图床托管于(Cloudflare Pages) 分享好看的天空和云(长期更新) Typecho转到Hexo(主题由Typecho-Joe-Theme转Butterfly主题) Typecho评论导出为Hexo的Valine、Twikoo等评论所支持的JSON文件 Safari浏览器内容被地址栏、菜单栏或工具栏遮挡导致的兼容问题 拼夕夕快速提现100元攻略 2024 平安喜乐
JavaScript屏蔽右键F12和Ctrl+U等绝大部分按键
.𝙃𝙖𝙣 · 2026-04-11 · via 韩小韩博客

avatar

.𝙃𝙖𝙣

一点 0分钟

Code

网站被别人抓包?被别人审查?被别人扒?

代码直接插入网页,不会的话,百度一下。

<script type="text/javascript">
	//屏蔽右键菜单
	document.oncontextmenu = function (event) {
		if (window.event) {
			event = window.event;
		}
		try {
			var the = event.srcElement;
			if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
				return false;
			}
			return true;
		} catch (e) {
			return false;
		}
	};
	//屏蔽粘贴
	document.onpaste = function (event) {
		if (window.event) {
			event = window.event;
		}
		try {
			var the = event.srcElement;
			if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
				return false;
			}
			return true;
		} catch (e) {
			return false;
		}
	};
	//屏蔽复制

	//屏蔽剪切
	document.oncut = function (event) {
		if (window.event) {
			event = window.event;
		}
		try {
			var the = event.srcElement;
			if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
				return false;
			}
			return true;
		} catch (e) {
			return false;
		}
	};
	//禁止f12

	function fuckyou() {
		window.close(); //关闭当前窗口(防抽)
		window.location = "about:blank"; //将当前窗口跳转置空白页
	}
	//禁止Ctrl+U
	var arr = [123, 17, 18];
	(document.oncontextmenu = new Function("event.returnValue=false;")), //禁用右键
		(window.onkeydown = function (e) {
			var keyCode = e.keyCode || e.which || e.charCode;
			var ctrlKey = e.ctrlKey || e.metaKey;
			console.log(keyCode + "--" + keyCode);
			if (ctrlKey && keyCode == 85) {
				e.preventDefault();
			}
			if (arr.indexOf(keyCode) > -1) {
				e.preventDefault();
			}
		});

	function ck() {
		console.profile();
		console.profileEnd();
		//我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!!
		if (console.clear) {
			console.clear();
		}
		if (typeof console.profiles == "object") {
			return console.profiles.length;
		}
	}

	function hehe() {
		if ((window.console && (console.firebug || (console.table && /firebug/i.test(console.table())))) || (typeof opera == "object" && typeof opera.postError == "function" && console.profile.length)) {
			fuckyou();
		}
		if (typeof console.profiles == "object" && console.profiles.length) {
			fuckyou();
		}
	}
	hehe();
	window.onresize = function () {
		if (window.outerHeight - window.innerHeight > 200)
			//判断当前窗口内页高度和窗口高度,如果差值大于200,那么呵呵
			fuckyou();
	};

	document.onkeydown = function (event) {
		if (
			event.keyCode == 112 || //屏蔽 F1
			event.keyCode == 113 || //屏蔽 F2
			event.keyCode == 114 || //屏蔽 F3
			event.keyCode == 115 || //屏蔽 F4
			// (event.keyCode == 116) || //屏蔽 F5
			event.keyCode == 117 || //屏蔽 F6
			event.keyCode == 118 || //屏蔽 F7
			event.keyCode == 119 || //屏蔽 F8
			event.keyCode == 120 || //屏蔽 F9
			event.keyCode == 121 || //屏蔽 F10
			event.keyCode == 122 || //屏蔽 F11
			event.keyCode == 123
		) {
			//屏蔽 F12
			return false;
		}
	};
	window.onhelp = function () {
		return false;
	};
</script>
屏蔽按键