humphreygaming / survivcustomsoundsandtextures

This is the hosting place for the custom sounds extension that SCI currently uses.
5 stars 13 forks source link

Q #10

Closed ghost closed 3 years ago

ghost commented 3 years ago

I don’t need these parts of the code? Also is background.js the code for the custom sounds?

ext.onBeforeRequest` = (details) => {
  if(replaces.has(details.url)){
    var replaced_url = chrome.extension.getURL(replaces.get(details.url));
    console.log(replaced_url);
    return {redirectUrl: replaced_url };
  }  
};

ext.install = () => {
  ext.remove();
  const extra = ['blocking', 'responseHeaders'];
  if (/Firefox/.test(navigator.userAgent) === false) {
    extra.push('extraHeaders');
  }
  chrome.webRequest.onHeadersReceived.addListener(ext.onHeadersReceived, {
    urls: ['https://surviv.io/*']
  }, extra);

  chrome.webRequest.onBeforeRequest.addListener(ext.onBeforeRequest, {
    urls: ['https://surviv.io/*']
  }, ['blocking']);
};
ext.remove = () => {
  chrome.webRequest.onBeforeRequest.removeListener(ext.onBeforeRequest);
  chrome.webRequest.onHeadersReceived.removeListener(ext.onHeadersReceived);
};

ext.install(); 
humphreygaming commented 3 years ago

You will need those, it works alongside the replacement feature (the top part of background.js is the sound replacement yes)