0

in the other words, I want when I put http://YYY .org/t/1212 on Chrome/Firefox search bar the browser automatically changes the URL (aka redirect) to http://XXX .org/t/1212

Please guide me to write a simple extension to do that.

UPDATE

I personally wrote a extension but still there's a problem :(

var url = window.location.href;     // Returns full URL
var rest = url.substring(20);
window.stop();
$(location).attr('href', 'http://imdb.com/'+rest)

but the browser load the http://YYY .org/t/1212 completely and then redirect to http://XXX .org/t/1212 . Is there any way to prevent the browser? I took some time and traffic

John K
  • 65
  • 7
  • To answer the portion of your question that isn't answered on the linked question: Yes this is definitely possible to do in a browser extension: https://stackoverflow.com/questions/4859689/how-do-i-redirect-to-a-url-using-a-google-chrome-extension-content-script – Rob M. Apr 03 '17 at 19:26
  • I know of a Firefox extension called *Greasemonkey*. There you can create JS files that are automatically executed on specific sites: https://addons.mozilla.org/de/firefox/addon/greasemonkey/ Chrome supports **User Scripts** out of the box. – Aloso Apr 03 '17 at 19:28
  • NorwayLover, We are gong to need more information from you. Are you specifically looking to write a Chrome extension/Firefox add-on to accomplish this task? Your question is really just asking if it is possible, which it is. – Makyen Apr 03 '17 at 19:46
  • This is not a duplicate of the question you have referred him to. He is asking if it is possible to make an extension do something very specific. He isn't asking how to redirect in JavaScript. There is much more of an answer required for how to do this with an extension. The Stackoverflow Trolls should not have closed this. – frosty Apr 03 '17 at 20:03
  • @Makyen I updated the dup-target and added a link to a Firefox-extension related answer as well. Thanks! – Rob M. Apr 03 '17 at 23:24
  • @RobM, Thanks for updating the dup-targets. The new capabilities for hammers are *very* convenient. I did not mention the WebExtensions question because that limitation has been removed from Firefox in an intervening version. However, they appear to have not documented well in which version the limitation was removed (grumble). – Makyen Apr 03 '17 at 23:36
  • @Makyen guys! guys! First word of the question is "HOW". You could have given me a start point and a solution. Saying just "yep, it's possible" not efficient. Anyway I personally wrote a extension. Of course it has a problem. Please help me to solve that minor problem! – John K Apr 04 '17 at 00:00
  • 1
    @NorwayLover, At this point, you should ask a new question which is about debugging your code. For that question, we will need a complete [mcve]. However, the question which is linked as the primary duplicate provides you with other methodologies which will not experience the problem you are having. OTOH, using the alternate methodologies described there is not the only way to solve the specific problem you are having with your current code. – Makyen Apr 04 '17 at 00:22

0 Answers0