chrome 开发并使用油猴 Tampermonkey 插件
2023-09-11 14:16:38 时间
背景:以前 test.user.js 的插件方式被 Chrome 封杀了。现在只能依赖油猴来编写自己的 js 插件。
官方网站:https://tampermonkey.net/
chrome商店: https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=zh-CN
tampermonkey 百度网盘本地安装:https://pan.baidu.com/s/19atulFTwe6Sp_bR5fjFF7A
不知道怎么本地安装 chrome 插件的同学可以参考我这篇文章:https://www.cnblogs.com/CyLee/p/10076458.html
安装完成后,Chrome 右上角插件列表如图所示:
点击添加新脚本
// ==UserScript== // @name New Userscript // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://www.baidu.com/* // @grant none // ==/UserScript== (function() { 'use strict'; window.alert('123'); })();
保存然后打开百度(注意是带https的百度哦),效果如图所示:
请注意代码中的 @match,这里必须必须写上你的匹配表达式。
请注意代码中的 @match,这里必须必须写上你的匹配表达式。
请注意代码中的 @match,这里必须必须写上你的匹配表达式。
再来一个实战的示例,给apizza的控制台加上滚动条。
// ==UserScript== // @name apizza.net // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://apizza.net/console/project/* // @match https://apizza.net/pro/* // @grant none // ==/UserScript== (function() { 'use strict'; var styles = document.createElement('style') styles.id = 'fuckyou' styles.type = 'text/css' document.getElementsByTagName('head')[0].appendChild(styles) // 新版本美化 styles.sheet.addRule('.tab-pane', 'margin-bottom: 20px') styles.sheet.addRule('.ace_editor.ace-eclipse', 'height: 350px !important') styles.sheet.addRule('.request-panel .response-content, .response-panel', 'min-height: 350px !important') // 旧版本美化 styles.sheet.addRule('#response-body', 'height: 350px; overflow: scroll;') styles.sheet.addRule('.panel-response-textarea', 'min-height: 350px !important') })();
效果如图所示:
相关文章
- 我的chrome 智能扩展插件copier开源了!!!
- ASP.NET Core 谷歌chrome 浏览器出现ERR_UNSAFE_PORT网页可能已永久移到新的网址的解决办法
- 【linux-command】Chrome安装linux-command插件
- 解决chrome插件安装时出现的“程序包无效”问题信息:程序包无效。
- [Debug] Copy a network request as fetch or cURL with Chrome DevTools
- [PWA] Add Push Notifications to a PWA with React in Chrome and on Android
- 基于chrome内核的.NET开发资源
- EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案中使用Onvif协议获取视频设备快照
- EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案使用详情功能-视频录像功能说明
- EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案之使用RTSP流判断摄像机设备是否在线以及快照抓取
- EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案之使用ffmpeg保存快照数据方法与代码
- EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案-Onvif(三)使用Onvif协议进行设备PTZ云台控制
- EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案-Onvif(二)使用Onvif协议进行设备RTSP地址获取
- EasyNVR摄像机网页Chrome无插件视频播放功能二次开发之通道配置文件上传下载示例代码
- 这些好用的 Chrome 插件,提升你的工作效率
- Chrome插件中 popup,background,contentscript消息传递机制
- javascript:得到变量类型的方法(chrome 105.0.5195.125)
- chrome扩展插件推荐:FeHelper格式化json
- [FE] Give some magic ! 那些奇思妙想的 Chrome 插件
- 关于 Chrome 开发者工具的 Lighthouse 面板
- 推荐一个可以把网页背景色调成护眼色的Chrome扩展应用
- selenium驱动chrome-等待等待下载完成后再下载下一个
- Chrome控制台的妙用之使用XPATH
- win7 chrome Regex Search 插件 正则表达式搜索
- Chrome插件网