Script tags stripping in xenOverlay

wasif

Member
Hello everyone,

Got into really strange problem. Basically I want to render some script right into overlay box.

Everything working perfectly fine except the "script" tags got removed automatically. After spending few minutes with Xenforo code I realized the file responsible for rendering Overlay stuff is doing this by purpose.

File: js/xenforo/xenforo.js
Line # 3377 (after deminifying it)
Code:
createOverlay: function(a, b, d) {
            var e = null,
                f = null,
                h = null,
                f = /<script[^>]*>([\s\S]*?)<\/script>/ig,
                j, h = [];
            if (b instanceof jQuery && b.is(".xenOverlay")) e = b.appendTo("body"), f = b;
            else {
                if (typeof b == "string") {
                    for (; j = f.exec(b);) h.push(j[1]);
                    b = b.replace(f, "")
                }
                f = c(b);
                f.is(".NoAutoHeader") || d && d.title && c('<h2 class="heading h1" />').html(d.title).prependTo(f);
                f.is(".formOverlay") && f.find(".submitUnit").length && (f.find(".submitUnit :reset").length || f.find(".submitUnit .button:last").after(c('<input type="reset" class="button OverlayCloser" />').val(XenForo.phrases.cancel)).after(" "));
                e = c('<div class="xenOverlay __XenForoActivator" />').appendTo("body").addClass(c(b).data("overlayclass")).append(f);

That's been said, now I want to request if anyone else in developer community can suggest how to disable this behaviour using plugin or what's the best way to accomplish this.

At this time I want my script to be in contact form with one extra field. The extra field is already there but useless when opened in overlay.

Just to clarify this further, my use case not allow me to put script stuff inside footer.
 
Hello,

You don't have to "deminify" the JS, the full version can be find in js/xenforo/full/xenforo.js.
createOverlay function starts at line 2130.

You should not insert <script> code into your HTML template.
Use rather XenForo.register to add a listener to a DOM element.
 
Thanks for speedy reply @Insy. I am aware of Xenforo.register but the problem here is bit different.

Basically I am creating a plugin from a captcha library. The way this thing is coded is quite restricted. Like I can't make changes to core library for this captcha.

After coding a plugin I tested it and its working like charm everywhere with code that captcha library is providing but in overlays its just not happening.

I am getting following script that I need to render on "renderInternal" method.

Code:
<input type="text" name="xyz">
<script src="a url with some dynamic stuff generated by captcha library"></script>
 
Thanks for speedy reply @Insy. I am aware of Xenforo.register but the problem here is bit different.

Basically I am creating a plugin from a captcha library. The way this thing is coded is quite restricted. Like I can't make changes to core library for this captcha.

After coding a plugin I tested it and its working like charm everywhere with code that captcha library is providing but in overlays its just not happening.

I am getting following script that I need to render on "renderInternal" method.

Code:
<input type="text" name="xyz">
<script src="a url with some dynamic stuff generated by captcha library"></script>

Hi @wasif

How did you solve this. I am having the same problem. Need to include an external js script in an overlay and it's being stripped. Did you resolve this?
 
Back
Top Bottom