计科知识库
  • 源界面
  • 博客圈
  • 专题
  • 博友
  • 登录
  • 注册
源界面 源界面 5天前

一个JS代码写的,实现打开调试或开发工具就关掉网页

js

:一个JS代码写的,实现打开调试或开发工具就关掉网页
功能是,只要打开web调试工具什么的,网站就关掉了。。。。

屏幕截图 2025-10-29 171846

  1. <script type="text/javascript">
  2. // 定义尝试关闭当前窗口并导航至空白页的函数
  3. function fuckyou() {
  4. window.close(); // 尝试关闭当前窗口
  5. window.location = "about:blank"; // 导航至空白页
  6. }
  7. // 使用console的profile方法来检测调试
  8. function ck() {
  9. console.profile();
  10. console.profileEnd();
  11. if (console.clear) {
  12. console.clear();
  13. };
  14. if (typeof console.profiles == "object") {
  15. return console.profiles.length > 0;
  16. }
  17. }
  18. // 检测Firebug等调试工具,若发现则调用fuckyou
  19. function hehe() {
  20. if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) ||
  21. (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) {
  22. fuckyou();
  23. }
  24. if (typeof console.profiles == "object" && console.profiles.length > 0) {
  25. fuckyou();
  26. }
  27. }
  28. // 更全面的开发者工具打开检测
  29. function comprehensiveCheck() {
  30. if (ck() || window.outerHeight - window.innerHeight > 200 || window.outerWidth - window.innerWidth > 200) {
  31. fuckyou();
  32. }
  33. }
  34. // 重新定义检测窗口尺寸变化的方法
  35. function onWindowSizeChange() {
  36. // 检测工具栏的高度
  37. var threshold = 160; // 设置一个阈值,因为开发者工具的高度通常会超过这个值
  38. var diffHeight = window.outerHeight - window.innerHeight;
  39. var diffWidth = window.outerWidth - window.innerWidth;
  40. if (diffHeight > threshold || diffWidth > threshold) {
  41. fuckyou();
  42. }
  43. }
  44. // 防止使用右键菜单和F12
  45. document.addEventListener('contextmenu', function(e) {
  46. e.preventDefault();
  47. });
  48. document.addEventListener('keydown', function(e) {
  49. if (e.keyCode === 123) { // F12
  50. e.preventDefault();
  51. }
  52. });
  53. // 页面加载和尺寸变化时的操作
  54. window.onload = function() {
  55. hehe();
  56. comprehensiveCheck();
  57. setInterval(function() {
  58. hehe();
  59. comprehensiveCheck();
  60. }, 2000);
  61. };
  62. // 在窗口尺寸变化时,调用修改后的检测函数
  63. window.onresize = onWindowSizeChange;
  64. </script>

源代码从这个地方获取的 https://www.afxw5.com/sygj

大家可以参考学习学习js的实用技巧

  • © 2025 源界面 源码为笔,博客为路,写就数字未来
  • 建议
  • 图片压缩
  • | 鄂ICP备14016484号-6

    鄂公网安备 42068402000140