-
Notifications
You must be signed in to change notification settings - Fork 17
console.log doesn't work from dotjs #27
Comments
+1 maybe the plugin could provide a wrapper/replacement for console and its methods that map to the actuall window.console |
+1 this makes debugging a whole lot harder |
// 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'); |
nice workaround. |
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 Is there any update on this? |
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? |
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 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. |
Another workaround is to use dot.js to append a new script element with src set to a second .js file.
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. |
Reported by @wraithan
The text was updated successfully, but these errors were encountered: