abdulmuneer22 / EmailSoundNotification

// ==UserScript==
// @name        EmailSoundNotification
// @namespace   jasonnea
// @include     *.amazon.com/gp/stores/*
// @version     1
// @grant       none
// ==/UserScript==

var eButton = document.getElementById("gn-ccp-incoming-email");

function playAlert(){
  var e = document.getElementById("gn-ccp-incoming-email");
  var acceptButton =document.getElementById("gn-ccp-incoming-email-accept-announce")
  var settingsGear = document.getElementsByClassName("gn-tab-heading gn-tab-heading-ccp");
 
  if(e.style.display != "none"){
    window.AudioContext = window.AudioContext || window.webkitAudioContext;

    context = new AudioContext();

    var o = context.createOscillator();
    o.type = 'square';
    o.frequency.value = 440;
    o.connect(context.destination);
    //document.getElementsByClassName("gn-tab-heading gn-tab-heading-ccp").click();
   
    $(".gn-icon-ccp").click()
    $("#gn-ccp-incoming-email-accept-announce").click()
    
    
    
    o.start(0);
    o.stop(0.133);
  }
}

var obs = new MutationObserver(playAlert);
var config = { attributes: true };
obs.observe(eButton,config);