【发布时间】:2021-03-12 17:41:17
【问题描述】:
这是我目前所拥有的:
function loadScript(url) {
return new Promise((resolve, reject) => {
let script = document.createElement('script');
script.onload = function() {
resolve();
};
script.src = url;
document.head.appendChild(script);
});
};
loadScript("https://rawgit2.com/icodeforlove/template-colors-web/master/dist-browser/template-colors.js").then(load);
function load() {
function logThing(pkt) {
pkt = pkt.join(', ');
console.log(c`${'['.red.bold}${pkt.green.bold}${']'.red.bold}`);
};
logThing(["Test", "thing", "here"]);
}
为什么 Tampermonkey 会这样做?我到底该如何解决这个问题?
【问题讨论】:
-
看起来像 Tampermonkey 中的一个错误。作为一种解决方法,您可以从虚拟 iframe example 中提取原始 console.log。