快速复制网站中的html与css样式代码

您所在的位置:网站首页 网页检查怎么复制代码 快速复制网站中的html与css样式代码

快速复制网站中的html与css样式代码

2024-07-16 07:54| 来源: 网络整理| 查看: 265

原理:把整个网页中元素的样式全部改为内连样式。 使用方式: 1、打开浏览器控制台。 2、运行以下脚本。 3、复制控制台输出。 4、新建一个html 文件,将复制的内容copy 到这个文件中。 5、浏览器中打开html文件就可看到该网站内容。

let select = 'body' if(!window.$ || !window.jQuery) { var x = document.createElement("SCRIPT"); x.setAttribute('src','https://code.jquery.com/jquery-2.2.4.min.js') document.body.appendChild(x); setTimeout(startRenderEl, 2000) } else { startRenderEl() } function startRenderEl() { let styles = [ 'color','background','width', 'height','fontSize','lineHeight', 'margin', 'padding','position', 'float','right', 'bottom','top','left', 'display','border', 'borderTop','borderBottom','borderLeft','borderRight', 'cursor','overflow','boxSizing','borderColor', 'borderRadius','textDecoration','listStyle', 'textAlign' ] dealItemEl(select) $(select+' *').each((index, el) => { dealItemEl(el) }) function dealItemEl(el) { if (typeof el === 'string') { el = $(el) } if (el instanceof jQuery) { el = el[0] } let styleObj = window.getComputedStyle(el) styles.forEach(v => { if (styleObj[v]) { $(el).css(v, styleObj[v]) } }) } let content = $('').append($(select).clone()).html(); console.log(content) }



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3