Redirecting scripts to greasemonkey

I have a Chrome extension that uses chrome.webRequest.onBeforeRequest.addListener to download fixed scripts / redirect some scripts download to another site. chrome.webRequest is perfect for me because it helps me load the "patched" script instead of the original one, not on top of it.

chrome.webRequest.onBeforeRequest.addListener(function(details){
  var originalUrl = details.url;
  console.log('originalUrl: ' + originalUrl);

  blockingResponse = {};

  if (originalUrl fits my condition) {
      blockingResponse.redirectUrl = originalUrl.performSomeLogicToGetNewUrl();
      console.log('redirectUrl: ' + blockingResponse.redirectUrl);
  }

  return blockingResponse;
},
{urls: [ "<all_urls>" ]},['requestBody','blocking']);

      

I want to go to a solution that works across multiple browsers and investigate if this can be achieved with greasemonkey / tampermonkey, but no luck so far. Does anyone have a similar experience?

+3


source to share





All Articles