以下 javascript 代码在我将其粘贴到 Chrome 检查控制台时有效;但我无法成功地将其用作书签。有人知道为什么吗?
我想做的是设置 css 样式 white-space: pre-wrap 以便正确查看预先格式化的表格。
javascript: void(! function(t, i) {
try {
if (!t || !i) return;
! function(e, t) {
if ("string" == typeof e && 0 < e.length && null === i.getElementById(t)) {
var n = i.createElement("style");
n.setAttribute("type", "text/css"), "string" == typeof t && 0 < t.length && n.setAttribute("id", t);
var r = i.createTextNode(e);
n.appendChild(r);
var o = i.getElementsByTagName("head");
0 < o.length && o[0].appendChild(n);
}
}("pre, code, kbd, samp {white-space: pre !important;}", "orospu-jupyter");
} catch (e) {
t && t.console && "function" == typeof t.console.error && t.console.error(e);
}
}(window, window.document));
最佳答案
因为书签只针对网页。不能将其用于脚本书签。对不起。
关于javascript 在控制台中工作,但不能作为书签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52202131/