Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:58:57+00:00 2026-06-13T15:58:57+00:00

I hope that somebody can help me. I want to redeclare js function by

  • 0

I hope that somebody can help me.
I want to redeclare js function by extension.
For example, there is the basic js function on website:

function foo(){
..something here..
}

i want to redeclare it by own function with the same name. how it will be easiest to do?

edit 1. i’ll try to explain better.

there is a native code in website:

Notifier = {
  debug: false,
  init: function (options) {
    curNotifier = extend({
      q_events: [],
      q_shown: [],
      q_closed: [],
      q_max: 3,
      q_idle_max: 5,
      done_events: {},
      addQueues: curNotifier.addQueues || {},
      recvClbks: curNotifier.recvClbks || {},
      error_timeout: 1,
      sound: new Sound('mp3/bb1'),
      sound_im: new Sound('mp3/bb2')
    }, options);

    if (!this.initFrameTransport() && !this.initFlashTransport(options)) {
      return false;
    }
    this.initIdleMan();

    if (!(curNotifier.cont = ge('notifiers_wrap'))) {
      bodyNode.insertBefore(curNotifier.cont = ce('div', {id: 'notifiers_wrap', className: 'fixed'}), ge('page_wrap'));
    }
  },
  destroy: function () {
    Notifier.hideAllEvents();
    curNotifier.idle_manager.stop();
    curNotifier = {};
    re('notifiers_wrap');
    re('queue_transport_wrap');
  },
  reinit: function () {
    ajax.post('notifier.php?act=a_get_params', {}, {
      onDone: function (options) {
        if (options) {
          curNotifier.error_timeout = 1;
          this.init(options);
        } else {
          curNotifier.error_timeout = curNotifier.error_timeout || 1;
          setTimeout(this.reinit.bind(this), curNotifier.error_timeout * 1000);
          if (curNotifier.error_timeout < 256) {
            curNotifier.error_timeout *= 2;
          }
        }
      }.bind(this),
      onFail: function () {
        curNotifier.error_timeout = curNotifier.error_timeout || 1;
        setTimeout(this.reinit.bind(this), curNotifier.error_timeout * 1000);
        if (curNotifier.error_timeout < 256) {
          curNotifier.error_timeout *= 2;
        }
        return true;
      }.bind(this)
    });
  }
}

and function Sound

function Sound(filename) {
  var audioObjSupport = false, audioTagSupport = false, self = this, ext;
  if (!filename) throw 'Undefined filename';

  try {
    var audioObj = ce('audio');
    audioObjSupport = !!(audioObj.canPlayType);

    if (('no' != audioObj.canPlayType('audio/mpeg')) && ('' != audioObj.canPlayType('audio/mpeg')))
      ext = '.mp3?1';
    else if (('no' != audioObj.canPlayType('audio/ogg; codecs="vorbis"')) && ('' != audioObj.canPlayType('audio/ogg; codecs="vorbis"')))
      ext = '.ogg?1';
    else
      audioObjSupport = false;
  } catch (e) {}
  // audioObjSupport = false;

  if (audioObjSupport) {
    audioObj.src = filename + ext;
    var ended = false;
    audioObj.addEventListener('ended', function(){ended = true;}, true);
    audioObj.load();
    this.playSound = function() {
      if (ended) {
        audioObj.load();
      }
      audioObj.play();
      ended = false;
    };
    this.pauseSound = function() {
      audioObj.pause();
    };
  } else {
    cur.__sound_guid = cur.__sound_guid || 0;
    var wrap = ge('flash_sounds_wrap') || utilsNode.appendChild(ce('span', {id: 'flash_sounds_wrap'})),
        guid = 'flash_sound_' + (cur.__sound_guid++);

    var opts = {
      url: '/swf/audio_lite.swf?4',
      id: guid
    }
    var params = {
      swliveconnect: 'true',
      allowscriptaccess: 'always',
      wmode: 'opaque'
    }
    if (renderFlash(wrap, opts, params, {})) {
      var swfObj = browser.msie ? window[guid] : document[guid],
          inited = false,
          checkLoadInt = setInterval(function () {
        if (swfObj && swfObj.paused) {
          try {
            swfObj.setVolume(1);
            swfObj.loadAudio(filename + ext);
            swfObj.pauseAudio();
          } catch (e) {debugLog(e);}
        }
        inited = true;
        clearInterval(checkLoadInt);
      }, 300);
      self.playSound = function() {
        if (!inited) return;
        swfObj.playAudio(0);
      };
      self.pauseSound = function() {
        if (!inited) return;
        swfObj.pauseAudio();
      };
    }
  }
}
Sound.prototype = {
  play: function() {
    try {this.playSound();} catch(e){}
  },
  pause: function() {
    try {this.pauseSound();} catch(e){}
  }
};

when i try to add injection with redeclaration function Sound it doesn’t work.
if i create my own function, for example, xSound and сall it this way:

cur.sound = new xSound('mp3/bb1');

it’s working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:58:59+00:00Added an answer on June 13, 2026 at 3:58 pm

    You can do it like this, for example:

    foo = function(args) {
        // method body...
    }
    

    JavaScript is a programming language where functions are first-class citizens so you can manipulate them like other types.

    UPDATE:

    Make sure that this piece of code actually does the redefinition and not the first definition. (thanks to @jmort253)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope that you can help me. When I want to execute those .bat
I hope somebody can help me here, I have a table that has the
I have a small problem, but I hope somebody can help. Let's say that
I have searched so much now and hope that somebody can help me. I
I have a problem with CodeIgniter .htaccess file and hope that somebody can help
I hope somebody can help me with this. I have a script that generates
Is there any way (utilizing Reflection I hope) that I can make an instantiated
HI, I hope somebody can help me here with the extjs framework. The problem
I need some advice here, I hope somebody can help me. I have the
I hope somebody can help me. how can I make addClass applies only to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.