how to make two different redirect url

46 views
Skip to first unread message

mohamed khaled

unread,
Dec 25, 2019, 9:37:29 AM12/25/19
to Chromium Extensions
I use webrequest.onBeforeRequest API to redirect URL according to a filter but I want to make another redirect URL after first one in which the first redirect URL happens then the second redirect works but I did first redirect URL but I have been trying to add second redirect but it doesn't work   
var host = "http://www.facebook.com";
for (i=0; i<1; i++){
 
var callback = function(details) {
   
var matching = details.url.match(/^https?:\/\/[^\/]+([\S\s]*)/)[1];
     
return {redirectUrl: host+matching};
 
}
 
var filter = {urls: blocked_domains}
 
var opt_extraInfoSpec = ["blocking"]
  chrome
.webRequest.onBeforeRequest.addListener(callback,filter, opt_extraInfoSpec);
}  
I want to add second redirect after first one happens

PhistucK

unread,
Dec 25, 2019, 11:17:44 AM12/25/19
to mohamed khaled, Chromium Extensions
Is http://www.facebook.com also in your permission list?

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/d5c28304-2589-4a63-9196-88f7b055abdf%40chromium.org.

mohamed khaled

unread,
Dec 25, 2019, 11:25:14 AM12/25/19
to Chromium Extensions, mohamed.k...@gmail.com
yeah I added to work with all websites 
"https://*/"



On Wednesday, 25 December 2019 18:17:44 UTC+2, PhistucK wrote:
Is http://www.facebook.com also in your permission list?

PhistucK


On Wed, Dec 25, 2019 at 4:37 PM mohamed khaled <mohamed.k...@gmail.com> wrote:
I use webrequest.onBeforeRequest API to redirect URL according to a filter but I want to make another redirect URL after first one in which the first redirect URL happens then the second redirect works but I did first redirect URL but I have been trying to add second redirect but it doesn't work   
var host = "http://www.facebook.com";
for (i=0; i<1; i++){
 
var callback = function(details) {
   
var matching = details.url.match(/^https?:\/\/[^\/]+([\S\s]*)/)[1];
     
return {redirectUrl: host+matching};
 
}
 
var filter = {urls: blocked_domains}
 
var opt_extraInfoSpec = ["blocking"]
  chrome
.webRequest.onBeforeRequest.addListener(callback,filter, opt_extraInfoSpec);
}  
I want to add second redirect after first one happens

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

PhistucK

unread,
Dec 25, 2019, 11:35:00 AM12/25/19
to mohamed khaled, Chromium Extensions
The pattern you just mentioned does not include all of the sites, it only includes secure websites (https), while you redirected (at least in the code you mentioned here) to the insecure URL (http) of the Facebook website.

PhistucK


On Wed, Dec 25, 2019 at 6:25 PM mohamed khaled <mohamed.k...@gmail.com> wrote:
yeah I added to work with all websites 
"https://*/"



On Wednesday, 25 December 2019 18:17:44 UTC+2, PhistucK wrote:
Is http://www.facebook.com also in your permission list?

PhistucK


On Wed, Dec 25, 2019 at 4:37 PM mohamed khaled <mohamed.k...@gmail.com> wrote:
I use webrequest.onBeforeRequest API to redirect URL according to a filter but I want to make another redirect URL after first one in which the first redirect URL happens then the second redirect works but I did first redirect URL but I have been trying to add second redirect but it doesn't work   
var host = "http://www.facebook.com";
for (i=0; i<1; i++){
 
var callback = function(details) {
   
var matching = details.url.match(/^https?:\/\/[^\/]+([\S\s]*)/)[1];
     
return {redirectUrl: host+matching};
 
}
 
var filter = {urls: blocked_domains}
 
var opt_extraInfoSpec = ["blocking"]
  chrome
.webRequest.onBeforeRequest.addListener(callback,filter, opt_extraInfoSpec);
}  
I want to add second redirect after first one happens

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/750990a7-e49a-4cf6-bbce-f372ae22472b%40chromium.org.

mohamed khaled

unread,
Dec 25, 2019, 12:01:59 PM12/25/19
to Chromium Extensions, mohamed.k...@gmail.com
I added all
["http://*/", "https://*/"]

but my problem is not this. I want to execute  redirect URL twice with different two URLs 


On Wednesday, 25 December 2019 18:35:00 UTC+2, PhistucK wrote:
The pattern you just mentioned does not include all of the sites, it only includes secure websites (https), while you redirected (at least in the code you mentioned here) to the insecure URL (http) of the Facebook website.

PhistucK


On Wed, Dec 25, 2019 at 6:25 PM mohamed khaled <mohamed.k...@gmail.com> wrote:
yeah I added to work with all websites 
"https://*/"



On Wednesday, 25 December 2019 18:17:44 UTC+2, PhistucK wrote:
Is http://www.facebook.com also in your permission list?

PhistucK


On Wed, Dec 25, 2019 at 4:37 PM mohamed khaled <mohamed.k...@gmail.com> wrote:
I use webrequest.onBeforeRequest API to redirect URL according to a filter but I want to make another redirect URL after first one in which the first redirect URL happens then the second redirect works but I did first redirect URL but I have been trying to add second redirect but it doesn't work   
var host = "http://www.facebook.com";
for (i=0; i<1; i++){
 
var callback = function(details) {
   
var matching = details.url.match(/^https?:\/\/[^\/]+([\S\s]*)/)[1];
     
return {redirectUrl: host+matching};
 
}
 
var filter = {urls: blocked_domains}
 
var opt_extraInfoSpec = ["blocking"]
  chrome
.webRequest.onBeforeRequest.addListener(callback,filter, opt_extraInfoSpec);
}  
I want to add second redirect after first one happens

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

PhistucK

unread,
Dec 25, 2019, 12:13:34 PM12/25/19
to mohamed khaled, Chromium Extensions
I understand your problem, but I thought that you might not have the right permission to intercept the redirected request. Now that you do, it might work. If it does not I am not sure what is the problem, perhaps redirecting bypasses the extension.

PhistucK


To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/4594b9d9-59ca-452c-a138-c2988e6a4c17%40chromium.org.
Reply all
Reply to author
Forward
0 new messages