排除的展示位置列表

获取排除的展示位置列表中的所有展示位置

function getPlacementsFromExcludedPlacementList(name) {
  const excludedPlacementListIterator =
      AdsApp.excludedPlacementLists()
          .withCondition(`shared_set.name = '${name}'`)
          .get();

  if (!excludedPlacementListIterator.hasNext()) {
    throw new Error(`No excluded placement list with name '${name}' found.`);
  }

  const excludedPlacementList = excludedPlacementListIterator.next();
  return excludedPlacementList.excludedPlacements().get();
}

将展示位置添加到排除的展示位置列表

function addPlacementToList(url, name) {
  const excludedPlacementListIterator =
      AdsApp.excludedPlacementLists()
          .withCondition(`shared_set.name = '${name}'`)
          .get();

  if (!excludedPlacementListIterator.hasNext()) {
    throw new Error(`No excluded placement list with name '${name}' found.`);
  }
  const excludedPlacementList = excludedPlacementListIterator.next();
  excludedPlacementList.addExcludedPlacement(url);
}