back to Noise icon Noise: Firefox Extension 中文版

Event Filter

  • more info Please note: these advanced settings may make troubles (ex: let Firefox crash),
    if you don't have interest to write custom code, directly pick items from Usage Examples would be a good idea.
  • more info Advanced users, or people like to play, please continue to read Setting Summary for more info.

Setting Summary

Usually we just fill topic or event type into the "event" field of Noise Edit window,
for example, dblclick will capture double clicking events.
And what is called Event Filtering, is to append an & with filter expression after the string,
then Noise will evaluate the result of the expression when events happen, and play sounds only if the result is true.
For example, dblclick&event['target'].tagName=='H1' checks if the clicked target is a H1 element, if so, continue to play a sound.

In the inner implementation of Noise 1.0,
the mentioned & with filter expression will become a function named filtertFx which will be called when events happen,
and parameters (event object, or subject and data objects) relevant to the event will be passed to it, and available for evaluating.

More detailed description:

If the event type is "Event topic - via addObserver" then the inner code of Noise 1.0 was:

observe: function(subject, topic, data) {
  try {
    if( filtertFx(subject,data) ) i['se'] );
  } catch(e) { dump('Noise: '+e); }

Definion of "subject" and "data", see nsIObserver - MDC;
In fact they are widely varies in different topics, see Global Notifications and so on;
Parameters of Noise-Specific topics, see Noise-Specific Topics.

If the event type is "Browser event - via gBrowser.addEventListener" or "Window event - window.addEventListener" then the relevant codes were:

this.listeners[i['urn']] = function(event) {
  try {
    if( filtertFx(event) ) i['se'] );
  } catch(e) { dump('Noise: '+e); }

Definition of "event" could be found in DOM-Level-2-Events.
Read event - MDC or Comparison of Event Targets for more information.

Noise-Specific Topics

Noise-Specific Topics
noise-TypeAheadFind.FIND_WRAPPEDnullaFindPreviousaFindPrevious can be true or false, "true" means finding backward (find previous)
noise-toggleSidebarnullcommandIDcommandID is the id of the toggle command, ex: when open History sidebar, the value is viewHistorySidebar
noise-WebProgress-startaReqaStatusaReq is a nsIRequest object, see nsIWebProgressListener for more information
noise-WebProgress-stopaReqaStatusaReq is a nsIRequest object, see nsIWebProgressListener for more information
noise-WebProgress-locationChangeaLocationaLocation.specaLocation is a nsIURI object, see nsIWebProgressListener for more information
noise-dl.addnewdlnulldl is the Download object, see onDownloadAdded of DownloadList#addView
noise-dl.removenewdlnulldl is the Download object, see onDownloadRemoved of DownloadList#addView
noise-dl.stopnewdlstatusdl is the Download object, see onDownloadChanged of DownloadList#addView;
data is the status of the download, with value set as one of 'succeeded', 'canceled' or 'stopped'
noise-dl.errornewdlerrordl is the Download object, see onDownloadChanged of DownloadList#addView;
data is the result property of error object, see DownloadError

Usage Examples

Type: 1 = Event topic 2 = Browser Event 3 = Window Event

ps. example may not available on old versions of Noise.

Noise Event Filter - Usage Examples
NameEvent StringTypeSummary
404 page not foundnoise-WebProgress-stop&subject.QueryInterface(Components.interfaces.nsIHttpChannel).responseStatus=='404'1when getting a 404 error page
404 resource not foundhttp-on-examine-response&subject.QueryInterface(Components.interfaces.nsIHttpChannel).responseStatus=='404'1when everytime getting 404 response
Address not foundnoise-WebProgress-stop&data==0x804B001E1can't find a host server
Failed to Connectnoise-WebProgress-stop&data==0x804B000D1though the site seems valid, connection failed
Reported attack site!noise-WebProgress-stop&data==0x805D001E1error: NS_ERROR_MALWARE_URI
Private browsingprivate-browsing&data=='enter'1replace 'enter' with 'exit' to capture exiting event.
Edit Bookmark Panelpopupshowing&'editBookmarkPanel'3panel shows when adding new bookmark
Specific URL LoadedDOMContentLoaded&''2,3please replace the URL part as needed
Specific info bar alertAlertActive&event.originalTarget.value=='popup-blocked'2,3 try also xpinstall, xpinstall-disabled,
blocked-plugins, missing-plugins,
refresh-blocked, offline-app-usage
Add-on installedem-action-requested&data=='item-installed'1 try also item-uninstalled,
item-enabled, item-disabled,
item-upgraded, item-cancel-action
Google Reader unread discoveredDOMAttrModified&'reading-list-unread-count'&&event.prevValue=='unread-count hidden'3with Google Reader opened, this fires when the count part of "All items (4)" appear
Findbar wrapped backnoise-TypeAheadFind.FIND_WRAPPED&data=='false'1true when going back to first (not last) result
Open bookmark sidebarnoise-toggleSidebar&data=='viewBookmarksSidebar'1
Search plugin discoveredDOMLinkAdded&'search'&&'application/opensearchdescription+xml'2,3happens even if you've already installed it
SearchWP fast search menuAlertActive&event.originalTarget.getAttribute('anonid')=='tokens-menu-popup'3
Open FoxAge2ch sidebarnoise-toggleSidebar&data=='viewBookmarksSidebar'1
FoxAge2ch error notifyfoxage2ch-global&data=='error-notify'1
FoxAge2ch finish checkingfoxage2ch-global&data=='finish-checking'1
FoxAge2ch subscribe donefoxage2ch-show-message&data=='(・∀・)完了'1
dblclick close Find bardblclick&event.button=='2'&&!gFindBar.hidden&&(gFindBar.close()||true)2double click right mouse button (on Windows) to close Find bar.

Other References