14

I'm using Greasemonkey, which sends errors to the Browser Console. I'm accessing this console by typing Ctrl+Shift+J.

The MDN docs contain links to https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Filtering_and_searching , but the link lands on a generic page. I am trying to filter out never-ending errors that look like:

10:26:36.122 Error: Permission denied to access property "postMessage"
g.L() www-widgetapi.js:94
g.P() www-widgetapi.js:91
1 www-widgetapi.js:94:312

I tried typing "-widget", "~widget", and "-permission" in the "filter output" toolbar, but they all screen out everything, such as errors of the form "missing { before try block". How can I make a filter that excludes, instead of includes?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Noumenon
  • 5,099
  • 4
  • 53
  • 73
  • 1
    Greasemonkey cannot control the console and the console filter appears to be very simple and positive only. You ***might*** be able to write a Firefox add-on that does this, but your most practical approach is to "tag" the messages you most want and filter ***for*** those. EG: `console.info("gmFilterOnMe ===>", {payload_message_here})`. – Brock Adams Feb 10 '16 at 17:18
  • 1
    [This](https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Console_messages#Filtering_by_text) indicates it is not currently possible. 'Filtering by text. To see only messages that contain a specific string, type in the text box labeled "Filter output"'. – Dan Cron Aug 16 '16 at 15:32
  • 3
    I know your question is specific to Firefox, but you can filter out console messages with regular expressions in Chrome. In Chrome, on the Console tab, select the filter icon, select Regex, and type in your filter. For example, to exclude errors containing the word widget, use the filter `^((?!widget)[\s\S])*$` – Dan Cron Aug 16 '16 at 21:28

2 Answers2

18

Nowadays you can also filter out errors in the Firefox console using the filter box (above the console), and even use regular expressions. A quick way to filter out things (Firefox 73+) is to put a minus '-' in front of the text you want to filter out e.g. '-jquery'. Note that in the original question there is also a minus in 'www-widgetapi' but this is apparently not a problem (tested).

neurosock
  • 496
  • 6
  • 13
  • 1
    Thanks. I found that you don't type `/whatever/` in the console, but in the filter box above the console. And you can't test it by making an error in the console yourself, since it doesn't hide those. I'm on Firefox 68, so the - didn't work for me yet and just hides everything. – Noumenon Apr 06 '20 at 02:43
  • 1
    Thanks for clarifying. I supposed you had already find a solution and answered it for future visitors ;-). I also had the same question and ended up in your post. I edited the answer above. – neurosock Apr 13 '20 at 10:15
1

You can negate a text search by prefixing it with the - character. For example, -img shows only items that do not contain the string img.

You can also use a valid regular expression to filter the console output. For example, filtering on two simple regular expressions: /(cool|rad)/ and /(cool)/.

You can negate a regular expression search by prefixing it with the - character. For example, -/(cool|rad)/ shows only items that do not match the expression /(cool|rad)/.

Details about Firefox filtering

SANDY
  • 189
  • 1
  • 5
  • Same info and link as the accepted answer, so it's a good answer (and better written) but I can't upvote. – Noumenon Apr 13 '23 at 13:19