Tampermonkey console.log 似乎与 chrome 开发工具中的不一样

Tampermonkey console.log doesn't seem to be the same as the one in chrome dev tools

这是我目前拥有的:

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 会这样做?我到底该如何解决这个问题?

还要记住,不使用 console.log 看起来像这样:

改为使用 @require 加载脚本:

// ==UserScript==
// @name         Whosebug question 66604679
// @version      0.1
// @author       Wolfy
// @match        
// @require      https://rawgit2.com/icodeforlove/template-colors-web/master/dist-browser/template-colors.js
// @grant        none
// ==/UserScript==
/* globals c */

(function() {    
  function logThing(wordsArray) {
    const stringToPrint = wordsArray.join(',');
    console.log(c`${'['.red.bold}${stringToPrint.green.bold}${']'.red.bold}`);
  }
  logThing(['Test', 'thing', 'here']);
})();

原因是在您的脚本中,<script> 被添加到页面上下文中,因此它没有修补 TM 的控制台。