简体   繁体   中英

Execute Code after specific Javascript runs

Simply, when this JavaScript is executed I need to add some CSS to be injected. However, I can't do that to this file as I don't have access to it so it needs to be done on the page level. I'm having trouble targeting it properly.

I've tested a couple things but haven't had any luck yet.

jQuery($("#mobileFilterModal").click(function() {
  alert("Btn 1 Clicked");
});

customFunction() {
  alert("Btn 1 Clicked");
}
mobileFilterModal().done( customFunction() );


function functionOne(x) {return x};

function functionTwo(var1) {
  console.log("it worked");
}
functionTwo(functionOne);


function myFunction() {
  console.log("sweet");
}

here's the part of the JavaScript file that I'm trying to target:

mobileFilterModal: function() {
            var a = ($("html").offset().top, $(window).height()),
                b = $(".klg-active-filter-modal");
            $(".klg-micrositeLogoTitle").hide(), $(".klg-micrositeTitle").hide(), $("html, body").css({
                height: a + "px",
                overflow: "hidden"
            }), 0 != $(".klg-actual-mainHeader").length ? ($("body").prepend('<div class="klg-hideBackGround"></div>'), b.find(".klg-newsfilter-modal").css({
                height: a - 90 + "px",
                "overflow-y": "scroll"
            })) : ($("body").prepend('<div class="klg-hideBackGround"></div>'), b.find(".klg-newsfilter-modal").css({
                height: a - 105 + "px",
                "overflow-y": "scroll"
            })), b.find(".klg-newsfilter-modal").addClass("klg-showModal").css(0 != $(".klg-actual-mainHeader").length ? {
                top: "-80px"
            } : {
                top: "-100px"
            }), b.find(".klg-newsfilter-modal").bind("touchmove", function(a) {
                $(this).scrollTop()
            }), $(".klg-newsfilter-modal").trigger("click")
        },
        hideFilterPopup: function() {
            $(".klg-hideBackGround").remove(), $(".klg-newsfilter-modal").removeClass("klg-showModal"), $(".klg-micrositeLogoTitle").show(), $(".klg-micrositeTitle").show(), $(".klg-news-filter-ParentSection").removeClass("klg-active-filter-modal"), $("html, body").on("touchstart touchmove", function(a) {
                $(this).css({
                    height: "auto",
                    overflow: ""
                })
            })
        },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM