简体   繁体   中英

append script to class / DIV

I am trying to append the following script in tampermonkey which should insert a script (adtag banner) into a div / class of a specific website but its not working.

// ==UserScript==
// @name         Insert TAG Into Class- zeit.com
// @require  https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @match       http*://www.website.xxx/*
// ==/UserScript==


(function () {
    var scriptElement = document.createElement( "script" );
    scriptElement.type = "text/javascript";
    scriptElement.src = "HTML SOURCE";
    $(".header").append(scriptElement);
})();

Do you have any ideas?

can you try this

$(".header").append(`<script type="text/javascript" src="../path"></script>`)

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