var doc = app.activeDocument;
var p = doc.selection[0].parentStory.paragraphs;
var pl = p.length;
var psN = doc.paragraphStyles.everyItem().name;
var psI = doc.paragraphStyles.everyItem().id;
var psg = doc.paragraphStyleGroups;
for (i=0;i<psg.length;i++){
var ps = psg[i].paragraphStyles;
for (j=0;j<ps.length;j++){
psN.push(ps[j].name+" ("+psg[i].name+")");
psI.push(ps[j].id);}}
var w = new Window ("dialog");
w.alignChildren = "left";
w.add("statictext",undefined,"Выбрать абзац со стилем:");
var nps = w.add("dropdownlist",undefined,psN);
nps.maximumSize.width = 150;
w.add("statictext",undefined,"Если за ним абзац со стилем:");
var nextps = w.add("dropdownlist",undefined,psN);
nextps.maximumSize.width = 150;
var bg = w.add("group");
bg.add("button",undefined,"OK");
bg.add("button",undefined,"Cancel");
if (w.show()!=1){exit();}
var nid = doc.paragraphStyles.itemByID(psI[nps.selection.index]);
var nextid = doc.paragraphStyles.itemByID(psI[nextps.selection.index]);
for (i=pl-2;i>0;i--){
if ((p[i].appliedParagraphStyle == nid)&&(p[i+1].appliedParagraphStyle == nextid)){
p[i].remove();
p[i-1].remove();
i--;}}
alert("Готово");