Modify URL before loading page in firefox

后端 未结 4 876
别那么骄傲
别那么骄傲 2020-12-03 05:52

I want to prefix URLs which match my patterns. When I open a new tab in Firefox and enter a matching URL the page should not be loaded normally, the URL should first be modi

4条回答
  •  悲哀的现实
    2020-12-03 06:57

    Is it possible to modify an URL through a Mozilla Firefox Addon before the page starts loading?

    YES it is possible.

    Use page-mod of the Addon-SDK by setting contentScriptWhen: "start"

    Then after completely preventing the document from getting parsed you can either

    1. fetch a different document from the same domain and inject it in the page.
    2. after some document.URL processing do a location.replace() call

    Here is an example of doing 1. https://stackoverflow.com/a/36097573/6085033

提交回复
热议问题