Topic on Skin talk:Medik

Jump to navigation Jump to search

Script injection in main content area fails?

10
Summary by Kghbln

Make sure that your CSS is sane in case something does not show up as expected or at all without other reason.

Kghbln (talkcontribs)

I am trying to add Google Adsense to "MediaWiki:Sitenotice" via a Widget and a second time using the "BeforePageDisplay" hook at the bottom of the main content area (class="col-12 col-md-9 col-xl-10 py-md-3 pl-md-5"). This works on Monobook however on Medik the two scrips seem to load according to the browser console however the Ads are not showing. Could you think of a reason for this? The respective wiki is AW-Wiki.

Note that in contrast the Google Adsense added to the Sidebar with the "SkinBuildSidebar" hook works as expected.

Slepi (talkcontribs)

Hmm, well, after some time I'm still not sure! I see that on AW-Wiki, the ads iframes are loaded both in the sidebar and in the sitenotice area, but they're empty for some reason. The sidebar's ad is sometimes visible, but not always. I'll have to explore it... maybe it's some problem in the widget's code (or something interferes with Google's scripts?).

Kghbln (talkcontribs)

Thanks a lot Slepi for having a look at this! I also wonder why this happens. For the sidebar I have not yet seen an issue but indeed for the two ads (sidenotice and content area). It will be really cool if the cause could be identified and ideally be fixed.

Slepi (talkcontribs)

I'm still not able to resolve this issue. :-( The sidebar's ad displays correctly, but the sitenotice is always empty (no matter what browser I use and no matter what script I re-run to parse the inserting element) without any error in the console. I will keep this open, only I want to make you sure that I didn't forget - even in these tought times. :-) Thanks for your patience!

Kghbln (talkcontribs)

Indeed this is really strange. Thanks a ton for continuing to look into this. If you add ?debug=true to the URL like e.g. https://www.aw-wiki.de/index.php/Hauptseite?debug=true and open the browser-console you can see a scary long list of script errors. Perhaps one of them? Unfortunately I am not a developer so I cannot make anything out of what I am seeing there.

Slepi (talkcontribs)

Yeah... the stragest thing is that it works in other skins! Those error messages are not very useful, thery way too general for me. I suspect some script blocks that execution, but still I can't figure out the error here.

One small thing is the width and height of the element, this should be:

style="display: inline-block; width: 928px; height: 90px;"

instead of:

style="display: inline-block; width: 928; height: 90"

so that the element is displayed correctly in Bootstrap-based skin, but still - it's empty, without an ad.

Still trying...

Kghbln (talkcontribs)

Thank you for continuing to have a look at this. These errors messages could have been a ray of hope for debugging but sometimes... I understand. :) Hopefully you will have the decisive idea.

Thanks also for the pointer to the missing units for the CSS. Just fixed. :)

Kghbln (talkcontribs)

@Slepi: You know what? Adding the units to the dimensions in the style statement fixed the issue! The ads are now displaying. Same for the ads at the very bottom. The code was added via configuration but had the same issue. After adding px this on was resolved. Both ads are served asynchronously.

The ad in the sidebar is served synchronously and specified the dimensions via explicit parameters height and width which the asynchronous code does not have. This is why this one was showing.

Obviously the other skins are not that picky here though admittedly it is perfect that Medik is enforcing valid CSS statements.

Thanks a lot for being a great help here!!! This is very much appreciated!!!

Slepi (talkcontribs)

@Kghbln Wow, really? I'm so glad it helped (although I didn't expect it at all, I thought it was a side accidental finding). :-) Thank you for such good news!

Kghbln (talkcontribs)

Really! It is amazing but true! This is indeed good news!