[英]How to persist CSS changes with Chrome Developer Tools
I'm trying to debug a drop-down menu.我正在尝试调试下拉菜单。 I don't have access to the website just yet so I'm trying to find a solution through Google Chrome Developer Tools which I can test and then apply to the site when I get access.
我还没有访问该网站的权限,所以我正在尝试通过 Google Chrome 开发人员工具找到一个解决方案,我可以测试该解决方案,然后在我获得访问权限时将其应用到该网站。 It's only CSS and perhaps some Javascript changes.
这只是 CSS,也许还有一些 Javascript 更改。
The problem is I want to apply some new CSS style rules through dev tools, but then have these persist upon refreshing the web page.问题是我想通过开发工具应用一些新的 CSS 样式规则,然后在刷新网页时保留这些规则。 Is there a way I can apply styles and get them to persist?
有没有办法可以应用样式并使它们持久化? I've looked at the resources section, which kind of suggests I can do something like this (maybe by adding a local style sheet as a resource?), but I just can't figure out how to do it.
我看过资源部分,哪种建议我可以做这样的事情(也许通过添加本地样式表作为资源?),但我不知道如何去做。
Could anyone point me in the right direction here?有人能在这里指出我正确的方向吗?
Many thanks folks...非常感谢各位...
You can install the Tampermonkey chrome extension, which is greasemonkey for chrome, and you can load userscripts that can alter css and use jquery to modify the page , and this changes are permanent as the script will be loaded and execute it automatically anytime you go to the site you set in the @match
rule, see the following userscript which just changes the background color of the page:您可以安装Tampermonkey chrome 扩展程序,它是 chrome 的greasemonkey,您可以加载可以更改 css的用户脚本并使用 jquery 修改页面,并且此更改是永久性的,因为脚本将被加载并在您访问时自动执行您在
@match
规则中设置的站点,请参阅以下仅更改页面背景颜色的用户脚本:
// ==UserScript==
// @name yourscript
// @namespace http://yeeeee/
// @version 0.1
// @description Change bacground color of page
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @match http://yourtargetsite.com/*
// @copyright 2012+, Me and Brothers
// ==/UserScript==
(function () {
$(document).ready(function(){
style = '<style type="text/css"> body {background-color: #CC7777 ! important;} </style>';
$('head').append(style);
});
})();
My favorite tools for CSS overriding is Stylish https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe我最喜欢的 CSS 覆盖工具是 Stylish https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe
It's useful for debugging and enhancing any web page.它对于调试和增强任何网页很有用。 There is also a large library of existing styles, with a convenient link to them from the extension menu.
还有一个很大的现有样式库,可以从扩展菜单方便地链接到它们。 Like these, for StackOverflow.com
像这些,对于StackOverflow.com
Since Version 65 of Chrome this can be done without plugins.从 Chrome 65 版开始,这可以在没有插件的情况下完成。 In the developer tools go to the Sources -> Overrides tab and select any local folder, where chrome should save your persistent changes to.
在开发人员工具中,转到Sources -> Overrides选项卡并选择任何本地文件夹,chrome 应将持久更改保存到该文件夹中。 For changes in the DOM tree, use the Sources and not the Elements tab.
对于 DOM 树中的更改,请使用Sources而不是Elements选项卡。
For a list of local overrides go to ⠇ -> More tools -> Changes .有关本地覆盖的列表,请转到⠇ -> More tools -> Changes 。
试试扩展stylebot ,它允许您为站点快速创建和保存持久的自定义 CSS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.