function onload(){
//Get the HTML element of the BPF Opportunity Stage button.
var opp_btn =window.top.document.querySelector("button[aria-describedby='MscrmControls.Containers.ProcessBreadCrumb-BPFStage_Description']");
var nxt_btn;
if(opp_btn!=null){
//Determines if the obtained button is the Opportunity Stage button. If not then exit.
if(!opp_btn.innerText.includes("Opportunity")){
return
}else{
ListenToNextStageNextStage();
}
}else{
//Continuously get the value of the Opportunity Stage button through callbacks until it is not null.
setTimeout(onload,10);
}
function ListenToNextStage(){
//Listen to the click event of the Opportunity Stage button.
opp_btn.addEventListener("click",function fn() {
//Get the Next Stage HTML element of the BPF Opportunity Stage.
nxt_btn = window.top.document.getElementById("MscrmControls.Containers.ProcessStageControl-nextButtonContainer")
if(nxt_btn!=null){
HideCreateNew();
}else{
//Continuously get the value of the Next Stage button through callbacks until it is not null.
setTimeout(fn,10);
}
})
}
function HideCreateNew(){
//Listen to the click event of the Next Stage button.
nxt_btn.addEventListener("click",function fn1() {
//Get the Create New HTML element of the BPF Opportunity Stage.
var cnew_btn = window.top.document.getElementById("MscrmControls.Containers.ProcessStageControl-CreateNewContainer")
if (cnew_btn!=null) {
// Hide the Create New button
cnew_btn.style.display = "none";
}else{
//Continuously get the value of the Create New button through callbacks until it is not null.
setTimeout(fn1,10)
}
})
}
}