How to override hook_page_build? I have below code coming from External Link module in Drupal 7:

/**
* Implements hook_page_build().
*/
function extlink_page_build() {
   $path = drupal_get_path('module', 'extlink');
   drupal_add_js($path .'/extlink.js', array('every_page' =&gt; TRUE));
   drupal_add_js(array('extlink' =&gt; array(
     'extTarget'     =&gt; variable_get('extlink_target', 0),
     'extClass'      =&gt; variable_get('extlink_class', 'ext'),
     'extLabel'      =&gt; check_plain(variable_get('extlink_label', t('(link is external)'))),
     'extImgClass'   =&gt; variable_get('extlink_img_class', 0),
     'extSubdomains' =&gt; variable_get('extlink_subdomains', 1),
     'extExclude'    =&gt; variable_get('extlink_exclude', ''),
     'extInclude'    =&gt; variable_get('extlink_include', ''),
     'extCssExclude' =&gt; variable_get('extlink_css_exclude', ''),
     'extCssExplicit' =&gt; variable_get('extlink_css_explicit', ''),
     'extAlert'      =&gt; variable_get('extlink_alert', 0),
     'extAlertText'  =&gt; variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.'),
     'mailtoClass'   =&gt; variable_get('extlink_mailto_class', 'mailto'),
     'mailtoLabel'   =&gt;   check_plain(variable_get('extlink_mailto_label', t('(link sends e-mail)'))),
   )), 'setting');
}


I want to add below code from above function only if my some condition is true (which will be based on some user filed) , without overriding files of module it self:

drupal_add_js(array('extlink' => array(
    'extTarget'     => variable_get('extlink_target', 0),)), 'setting');

I am not getting any solution how to override this function thorough my custom module, Please suggest !

To make more clear I just want to add condition in above function so that js will only get added if condition according to user field is true.

UPDATE: I have tried like below code but its not working, please suggest what I am doing wrong My custom module name: custom_overrides

function custom_overrides_page_alter(&amp;$page) {
   global $user;
   $userid = $user-&gt;uid; 

    if($userid){
        $path = drupal_get_path('module', 'extlink');
        drupal_add_js($path .'/extlink.js', array('every_page' =&gt; TRUE));
        drupal_add_js(array('extlink' =&gt; array('extTarget' =&gt; variable_get('extlink_target', 0),)), 'setting');
  }
}


Thanks!
In hook_page_alter you can override js settings just by using drupal_add_js like you pasted above.