当前位置: 首页 > news >正文

[JQuery] inject jQuery into any webpage

 

 

You can easily inject jQuery into any webpage so you can use it directly in your Chrome DevTools console. Here are several precise methods, from simplest to most robust:


Method 1 — Inject via Console

Open the Chrome console (Ctrl+Shift+J or Cmd+Option+J), then paste this:

var script = document.createElement('script');
script.src = "https://code.jquery.com/jquery-3.7.1.min.js";
script.integrity = "sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=";
script.crossOrigin = "anonymous";
document.head.appendChild(script);

Then press Enter.

After it loads (a second or two), test with:

typeof jQuery

It should return "function" if loaded successfully.


Method 2 — Bookmarklet (Reusable)

Create a browser bookmark and set its URL to this code:

javascript:(function(){var script=document.createElement('script');script.src='https://code.jquery.com/jquery-3.7.1.min.js';script.integrity='sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=';script.crossOrigin='anonymous';document.head.appendChild(script);
})();

Then, whenever you’re on a page that doesn’t have jQuery, click the bookmark — jQuery will be injected automatically.


Method 3 — Manually Add in the Console Network Context (if CSP blocks it)

If the site uses Content Security Policy (CSP) blocking inline scripts, run this in the console:

fetch("https://code.jquery.com/jquery-3.7.1.min.js").then(r => r.text()).then(code => eval(code));

This fetches and evaluates the script directly, bypassing most CSP restrictions.


Method 4 — Using Chrome Snippets

If you inject jQuery frequently:

  1. Open DevTools → Sources → Snippets.

  2. Create a new snippet called Inject jQuery.

  3. Paste the code from Method 1.

  4. Save it, and whenever you want jQuery available, right-click → Run.


Would you like me to include a version that auto-detects if jQuery is already loaded and replaces or skips accordingly?

 

http://www.rkmt.cn/news/47200.html

相关文章:

  • 必看!上下文工程在智能家居的10个关键知识点,架构师整理 - 教程
  • tomcat/idea打包部署报错,RUN 可以 DEBUG 不行
  • 在CMake中打印所有变量
  • .NET 10发布和它的新增功能
  • 2025年EGUOO关节灵活营养素:深度解析七重配方科研链与临床实证
  • 2025年EGUOO关节灵活营养素:深度解析七重配方与专利矩阵
  • 详细介绍:Tomcat核心组件全解析
  • 2025年EGUOO调理肠胃健壮身体粉深度解析:科研壁垒与四重功效全盘点
  • 系统流量突然增加了10倍,该怎么办?
  • 接口(接口中的所有定义都是抽象的,都需要实现类)
  • Local Persistent Volume
  • Plan-and-Execute Agents
  • 无问智推:开启数据消费新范式
  • revit esc取消报错处理
  • 2025年定制全屋家居公司权威推荐榜单:全屋定制装修/全屋定制品牌/全屋定制源头公司精选
  • MATLAB实现图像去模糊
  • 家庭相册私有化:Immich+cpolar构建你的数字记忆堡垒 - 详解
  • 2025年正式整理5款免费在线客服系统软件
  • npm yarn pnpm 区别
  • 文档内容比对桌面软件V2.2.0(新增详细报告输出)
  • matplotlib 中文显示异常的修复方法
  • 2025年卧式数控车床优质厂家推荐排行榜单
  • 2025年11月5日一星期
  • 2025年高速高压旋转接头权威推荐榜单:导热油旋转接头/液压多通路旋转接头/高速旋转接头源头厂家精选
  • 传统油烟机智能化升级之雷达手势感应唤醒控制方案
  • 2025年免清洗锡膏定制厂家口碑排行榜单
  • 2025年无骨架类变压器工厂口碑推荐榜
  • 完整教程:【Kafka】架构原理、消息丢失、重复消费、顺序消费、事务消息
  • Linux rsyslog 远程日志同步操作
  • 2025年提分系统平台口碑排行