Closed
Bug 1345233
Opened 9 years ago
Closed 9 years ago
webRequest doesn't work on Firefox Nightly
Categories
(WebExtensions :: Request Handling, defect)
Tracking
(Not tracked)
RESOLVED
WORKSFORME
People
(Reporter: github, Unassigned)
Details
Attachments
(1 file)
|
85.29 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Build ID: 20170307030205
Steps to reproduce:
Create a new extensions with the third code example on this page:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onBeforeRequest
Also here as code: http://pastebin.com/raw/xkULEme0
Use the follow manifest.json:
{
"name": "Youtube UHD",
"short_name": "youtube-uhd",
"description": "Youtube UHD allows you to always search for UHD videos",
"author": "Patrick Albrecht",
"version": "0.0.1",
"manifest_version": 2,
"permissions": [
"*://mdn.mozillademos.org/*",
"webRequest",
"webRequestBlocking"
],
"background":{
"scripts":[
"background.js"
]
},
"homepage_url": "https://google.com",
"icons": {
"60": "data/icons/icon.png"
}
}
Actual results:
The image are not replaced.
See the attachment for the browser log.
Expected results:
The images on this page should have been replaced with the image from tumblr.
Comment 1•9 years ago
|
||
The webRequest API definitely does work on Firefox Nightly. Exactly which image are you expecting to be replaced, on exactly which page?
| Reporter | ||
Comment 2•9 years ago
|
||
I'm just follow closely this documentation page (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onBeforeRequest).
I expecting that the blue firefox logo on this page (https://developer.mozilla.org/en-US/Firefox/Developer_Edition) should be replaced with this one (https://38.media.tumblr.com/tumblr_ldbj01lZiP1qe0eclo1_500.gif)
Updated•9 years ago
|
Component: Untriaged → WebExtensions: Request Handling
Product: Firefox → Toolkit
Comment 3•9 years ago
|
||
(In reply to Patrick Albrecht from comment #2)
> I expecting that the blue firefox logo on this page
> (https://developer.mozilla.org/en-US/Firefox/Developer_Edition) should be
> replaced with this one
> (https://38.media.tumblr.com/tumblr_ldbj01lZiP1qe0eclo1_500.gif)
That page is not on mdn.mozillademos.org, so it doesn't match either your permission or your filter.
| Reporter | ||
Comment 4•9 years ago
|
||
Nooo, that's so embarrassing :(
I just followed the instructions and didn't check the url self...
But I still don't get any better result, the image are still the same.
manifest.json:
{
"name": "Youtube UHD",
"short_name": "youtube-uhd",
"description": "Youtube UHD allows you to always search for UHD videos",
"author": "Patrick Albrecht",
"version": "0.0.1",
"manifest_version": 2,
"permissions": [
"*://developer.mozilla.org/*",
"webRequest",
"webRequestBlocking"
],
"background":{
"scripts":[
"background.js"
]
},
"homepage_url": "https://google.com",
"icons": {
"60": "data/icons/icon.png"
}
}
background.js:
// match pattern for the URLs to redirect
var pattern = "https://developer.mozilla.org/*";
// redirect function
// returns an object with a property `redirectURL`
// set to the new URL
function redirect(requestDetails) {
console.log("Redirecting: " + requestDetails.url);
return {
redirectUrl: "https://38.media.tumblr.com/tumblr_ldbj01lZiP1qe0eclo1_500.gif"
};
}
// add the listener,
// passing the filter argument and "blocking"
browser.webRequest.onBeforeRequest.addListener(
redirect,
{urls:[pattern], types:["image"]},
["blocking"]
);
Checked again browser log with no new entry and also did a forced refresh.
Comment 5•9 years ago
|
||
The URL of that image also doesn't match your filter. It's https://developer.cdn.mozilla.net/static/img/logo_sprite.7d36c4a1422b.svg
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
| Reporter | ||
Comment 6•9 years ago
|
||
Sorry for the circumstances; I think I shouldn't start to develop extensions when it so complicated.
Updated•8 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•