Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

console.log doesn't work from dotjs #27

Open
rlr opened this issue Mar 28, 2013 · 8 comments
Open

console.log doesn't work from dotjs #27

rlr opened this issue Mar 28, 2013 · 8 comments

Comments

@rlr
Copy link
Owner

rlr commented Mar 28, 2013

Reported by @wraithan

@Zauberfisch
Copy link

+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
Copy link

fcoury commented May 28, 2014

+1

this makes debugging a whole lot harder

@szepeviktor
Copy link

// 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
Copy link

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

@jish
Copy link

jish commented Oct 10, 2014

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
Copy link

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
Copy link

DonKult commented Feb 23, 2016

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
Copy link

mspreij commented Mar 8, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants