How can I execute a custom code on node edit/add page during hook_page_build?
The request_path() function can lookup the current path to determine what page is being rendered.

  if (request_path() == 'node/add/object') {
    // @TODO: Add code
  }
  else if (preg_match('/node\/\d+\/edit/', request_path())) {
    $node = menu_get_object();
    if ($node-&gt;type == 'object') {
      // @TODO: Add code for editing node
    }
  }