rlr / dotjs-addon

[unmaintained] ~/.js for Firefox
BSD 3-Clause "New" or "Revised" License
144 stars 17 forks source link

console.log doesn't work from dotjs #27

Open rlr opened 11 years ago

rlr commented 11 years ago

Reported by @Wraithan

Zauberfisch commented 10 years ago

+1 this is the probably most pressing issue I just tested it in chrome, seems to be working well there. is this a limitation of firefox/firebug?

maybe the plugin could provide a wrapper/replacement for console and its methods that map to the actuall window.console

fcoury commented 10 years ago

+1

this makes debugging a whole lot harder

szepeviktor commented 10 years ago
// Draw a nice box
// colors: http://flatuicolors.com/
(function () {
    var consoleBox = document.createElement('div');

    consoleBox.id = 'console-box';
    consoleBox.style.backgroundColor = '#bdc3c7';
    consoleBox.style.opacity = '0.80';
    consoleBox.style.borderRadius = '5px';
    consoleBox.style.position = 'fixed';
    consoleBox.style.left = '50px';
    consoleBox.style.top = '50%';
    consoleBox.style.bottom = '50px';
    consoleBox.style.width = '500px';
    consoleBox.style.padding = '10px';
    consoleBox.style.fontFamily = 'mono-spaced';

    document.body.appendChild(consoleBox);
}());

console = {
    box: document.getElementById('console-box'),

    lines: 0,

    addline: function (msg, color) {
        var line = document.createElement('p');

        this.lines += 1;

        line.style.color = color;
        line.textContent = this.lines + ': ' + msg;

        this.box.appendChild(line);
    },

    log: function (msg) {
        this.addline(msg, '#2c3e50');
    },

    error: function (msg) {
        this.addline(msg, '#e74c3c');
    }

}
console.log('apple');
console.error('pear');

https://gist.github.com/szepeviktor/bb1d65421e88d0896538

Zauberfisch commented 10 years ago

nice workaround. but I still would love to see this issue fixed

jish commented 9 years ago

Cool extension!

I just made a plugin to add back the Octocats to the empty notifications page on GitHub since they recently removed them https://gist.github.com/jish/446f0d91e1339e7aba07

But I agree console.log would have made development a little bit easier.

Is there any update on this? Is it a limitation with Firefox extensions?

dufferzafar commented 9 years ago

I would like to work on this thing, but I have absolutely no experience with FF addons. I'm installing the Addon SDK right now to fiddle around with things.

Can someone point me in the right direction?

DonKult commented 8 years ago

The trick to get the console logging working [at least as long as the console is open] is setting the logLevel lower (as it defaults to error) as described in Mozilla Add-ons Blog: Changes to console.log behavior in SDK 1.14

So, you open about:config and add a new string option extensions.jid0-HC7vB1GcMVr7IBB5B5ADUjTJB3U@jetpack.sdk.console.logLevel and set it to all.

Would be nice if dotjs could set that option by default – unfortunately I have no experience with extension development and my naive searchs always ended up in XUL land which smelt wrong, so no patch… hope that helps anyway.

mspreij commented 8 years ago

Another workaround is to use dot.js to append a new script element with src set to a second .js file.

$('<script/>').attr('src', '//domain.tld/foo.js').appendTo($('body'));

It can even sit on localhost, as long as it's not trying to load http in a https page. Strangely, this made console.log work except if the second js page was loaded from the same domain as the original site. This also allows one to redefine existing functions, which I think was tricky using just dot.js files.