See if this does what you need. Best I could tell you want to add a new page at the end of the document, based on master B. The script had the name of the master page as B-Masterpage, but without renaming the master page it is actually B-Master. Let me know if it isn't what you need and I can probably tweak it for you.
---
dostuff();
function dostuff(){
var curDoc = app.activeDocument,
allPages = curDoc.pages,
nPages = allPages.length;
newMaster = curDoc.masterSpreads.itemByName("B-Master");
for (i = nPages-1; i >= 0; i--) {
curPage = allPages;
p = curDoc.pages.add({appliedMaster: newMaster});
//~ p.move(LocationOptions.AFTER, END);
}
}
---
---
dostuff();
function dostuff(){
var curDoc = app.activeDocument,
allPages = curDoc.pages,
nPages = allPages.length;
newMaster = curDoc.masterSpreads.itemByName("B-Master");
for (i = nPages-1; i >= 0; i--) {
curPage = allPages;
p = curDoc.pages.add({appliedMaster: newMaster});
//~ p.move(LocationOptions.AFTER, END);
}
}
---