Last active
August 29, 2015 13:58
-
-
Save ZER0/10018525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add `contentType` to page-mod: | |
// https://bugzilla.mozilla.org/show_bug.cgi?id=788224 | |
// current API: | |
// all the http/https urls | |
PageMod({ | |
include: '*', // can take string | |
contentScript: 'console.log("hello")' | |
}); | |
// all the urls (e.g. resource) that contains `foo` | |
PageMod({ | |
include: /foo/i, // can take regexp | |
contentScript: 'console.log("hello")' | |
}); | |
// all the http/https urls, | |
// plus all the urls (e.g. resource) that contains `foo` | |
PageMod({ | |
include: ['*', /foo/i], // can take arrays with both of the previous values | |
contentScript: 'console.log("hello")' | |
}); | |
/* new API */ | |
// code above will still working, plus: | |
// all the http/https urls | |
PageMod({ | |
include: { | |
url: '*' // same as the first example | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// all the urls (e.g. resource) that contains `foo` | |
PageMod({ | |
include: { | |
url: /foo/i // same as the second example | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// all the http/https urls, | |
// plus all the urls (e.g. resource) that contains `foo` | |
PageMod({ | |
include: { | |
url: ['*', /foo/i], // same as the third example | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// all the http/https urls, | |
// but only if the document is an image | |
// with `contentType`: | |
PageMod({ | |
include: { | |
url: '*', | |
contentType: 'image/*' | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// all the urls (e.g. resource) that contains `foo`, | |
// but only if the document is an audio | |
PageMod({ | |
include: { | |
url: /foo/i, | |
contentType: 'audio/*' | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// all the http/https urls, | |
// plus all the urls (e.g. resource) that contains `foo`, | |
// but only if the document is an image | |
PageMod({ | |
include: { | |
url: ['*', /foo/i], | |
contentType: 'image/*' | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// all the http/https urls, | |
// plus all the urls (e.g. resource) that contains `foo`, | |
// but only if the document is a PNG or a gif | |
PageMod({ | |
include: { | |
url: ['*', /foo/i], | |
contentType: ['image/gif', 'image/png'] | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// you can omit `url` and having only `contentType`, | |
// in such case the default `url` will be "*": | |
PageMod({ | |
include: { | |
contentType: 'image/*' | |
}, | |
contentScript: 'console.log("hello")' | |
}); | |
// But you need to pass either `url` or `contentType` if you pass an object. | |
// This is should raise an exception during the validation | |
PageMod({ | |
include: { | |
foo: 'hello' | |
}, | |
contentScript: 'console.log("hello")' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment