HTML中多行的样式"style=-lns…"在Chrome控制台中显示。

huangapple go评论84阅读模式
英文:

HTML multiple line of "style=-lns..." showing in Chrome console

问题

出于某种原因,我开始在我的控制台中看到这个,但我不知道为什么:

HTML中多行的样式"style=-lns…"在Chrome控制台中显示。

这是我的代码中的全部内容。

<!DOCTYPE html>
<html lang="en">
<head>
  <title>JS Sandbox: Section 2</title>
</head>
<body>
  <h1>JS Sandbox: Section 2</h1>
  <!-- <script src="app.js"></script> -->
</body>
</html>

有人知道为什么会发生这种情况,以及我如何可能隐藏它或将它恢复到只有<html lang="en">的默认状态吗?

注意:我正在使用VSC。

英文:

For some reason I started to see this in my console and I don't know why:

HTML中多行的样式"style=-lns…"在Chrome控制台中显示。

Here is all that is in my code.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>JS Sandbox: Section 2</title>
</head>
<body>
  <h1>JS Sandbox: Section 2</h1>
  <!-- <script src="app.js"></script> -->
</body>
</html>

Does anyone know why this happens and how I can maybe hide it or bring it back to the default where there is just <html lang="en">?

Note: I am using VSC

答案1

得分: 3


以下是移除所有网站上HTML标签的`--lns`属性的代码示例,一种方法是使用一个用户脚本,该脚本在所有网站上运行,迭代`<html>`标签上的样式属性,并在属性以`--lns`开头时将其删除:

// ==UserScript==
// @name Remove HTML lns
// @match :///*
// @grant none
// ==/UserScript==

const html = document.documentElement;
const style = html.getAttribute('style');
const cleanedStyle = style
.split(' ')
.filter(str => !str.startsWith('--lns'))
.join(' ');
html.setAttribute('style', cleanedStyle);


您将需要一个用户脚本管理器,例如[Tampermonkey](https://www.tampermonkey.net/)。

如果这似乎不起作用,属性可能是在用户脚本加载*之后*添加的,这种情况下,您可以将整个用户脚本代码放在`setTimeout`中(或者在DOMContentLoaded事件上),例如

```javascript
setTimeout(() => {
  // 代码放在这里
}, 2000);

这样,当您检查DOM时,它将是清洁的。

某种东西正在向<html>添加所有这些属性,可能是一个扩展程序 - 删除这些属性可能会导致添加它们的任何内容无法正常显示。

您可以通过逐个浏览器扩展程序并禁用它们来找出原因,然后查看style属性上的所有杂乱内容何时出现。如果您能确定原因,您还可以禁用该扩展程序,但您将失去扩展程序提供的其他功能。```

英文:

If you want to remove the --lns properties from the HTML tag on all sites, one option is to use a userscript that runs on all sites that iterates over the style properties on the <html> and deletes them if they start with --lns:

// ==UserScript==
// @name         Remove HTML lns
// @match        *://*/*
// @grant        none
// ==/UserScript==

const html = document.documentElement;
const style = html.getAttribute('style');
const cleanedStyle = style
  .split(' ')
  .filter(str => !str.startsWith('--lns'))
  .join(' ');
html.setAttribute('style', cleanedStyle);

You'll need a userscript manager like Tampermonkey.

If this doesn't seem to work, the properties might be getting added after the userscript loads, in which case you can put the whole code of the userscript in a setTimeout (or on DOMContentLoaded), eg

setTimeout(() => {
  // code goes here
}, 2000);

so that by the time you might Inspect the DOM, it'll be clean.

Something is adding all those properties to the <html>, probably an extension - removing the properties might cause whatever added them to stop displaying properly.

You can probably figure out the cause by going through your browser extensions one-by-one and disabling them, then seeing when all the junk on the style attribute appears. If you can identify the cause, you can also just disable the extension, but you'll lose whatever other functionality the extension provides.

答案2

得分: 0

请检查是否安装了Loom视频录制扩展程序
在chrome://extensions/中禁用它
然后返回您的页面并重新加载
这对我有效。

英文:

Hi Please check if you have Loom video recorder extension
Disable it from chrome://extensions/
then come to your page and reload.
It worked for me.

huangapple
  • 本文由 发表于 2020年1月4日 11:43:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/59587699.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定