Jump to content
[MUST READ] Forum Rules ×

Add an Ad Unit on top-right side of the Cpanel


Recommended Posts

I already add one in the lower right side (through Your Adverts -> Control Panel Advert Control), does anyone know how to add an ad unit on the top right? Like the screenshot I provide?

rFNLjog.thumb.png.da79a8ddde34eed37af758f57278ffc6.png

I used the following insertAdjacentHTML  in the "advert" section
 

<script type="text/javascript">
var d1 = document.getElementById('one');
d1.insertAdjacentHTML('afterend', '<div id="two">two</div>');
</script>

But it won't function, only show its text form.

Link to comment
Share on other sites

  • 2 months later...

Thank you.

Can you please be so kind to tell me, which part to add to the Panel advert display?

if I need the advertise to be on the top right, like the screenshot of my first post, what shall I put in the "Right advert for mysite.com"?

I tried many times, and I don't know how to do it.

On 12/6/2021 at 12:23 PM, BastelPichi2 said:

Hey,

Heres the best method to just steal from InfinityFree. Heres modified version of hans' code, i just copy-pasted the needed part, you have to change it to your needs of course:



function buildAdSenseAdPanel(e) {
    let t = document.createElement("div");
    return (
        t.setAttribute("class", "panel panel-widget"),
        (t.innerHTML =
            '<div class="panel-heading widget-heading">Advertisement</div><div class="panel-body"><div class="col-xs-12 col-md-12 text-center"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7281184434591176" data-ad-slot="3301284143" data-ad-format="auto"></ins></div></div>'),
        t
    );
}
function insertStatsPanelAds() {
    let e = document.getElementById("stats"),
        t = buildAdSenseAdPanel(3855191122);
    e.insertBefore(t, e.firstChild), (adsbygoogle = window.adsbygoogle || []).push({});
    let n = buildAdSenseAdPanel(3472047746);
    e.appendChild(n), (adsbygoogle = window.adsbygoogle || []).push({});
}
document.addEventListener("DOMContentLoaded", function () {
    insertStatsPanelAds()
});

 

 

Link to comment
Share on other sites

  • 6 months later...
On 12/6/2021 at 10:53 PM, BastelPichi said:

Hey,

Heres the best method to just steal from InfinityFree. Heres modified version of hans' code, i just copy-pasted the needed part, you have to change it to your needs of course:

function buildAdSenseAdPanel(e) {
    let t = document.createElement("div");
    return (
        t.setAttribute("class", "panel panel-widget"),
        (t.innerHTML =
            '<div class="panel-heading widget-heading">Advertisement</div><div class="panel-body"><div class="col-xs-12 col-md-12 text-center"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7281184434591176" data-ad-slot="3301284143" data-ad-format="auto"></ins></div></div>'),
        t
    );
}
function insertStatsPanelAds() {
    let e = document.getElementById("stats"),
        t = buildAdSenseAdPanel(3855191122);
    e.insertBefore(t, e.firstChild), (adsbygoogle = window.adsbygoogle || []).push({});
    let n = buildAdSenseAdPanel(3472047746);
    e.appendChild(n), (adsbygoogle = window.adsbygoogle || []).push({});
}
document.addEventListener("DOMContentLoaded", function () {
    insertStatsPanelAds()
});

 

Bro i added this code and edited data-ad-client.

But it just sends text on cpanel

Screenshot_2022-08-27-15-26-43-359_com.android.chrome.jpg

Link to comment
Share on other sites

5 minutes ago, RoshanOp said:

Bro i added this code and edited data-ad-client.

But it just sends text on cpanel

Screenshot_2022-08-27-15-26-43-359_com.android.chrome.jpg

This is JavaScript.

 

You need to place this code between <script> tags.

 

Example:

<script>

//JavaScript code here.

</script>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...