Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom JavaScript in 'MediaWiki:Common.js' is not working

  1. I fresh installed MediaWiki on my own server (latest version)

  2. I tried adding some JavaScript code to MediaWiki:Common.js

  3. In localsettings.php, $wgAllowUserJs is set to true

  4. I also tried adding the JavaScript to User:Admin/vector.js and User:Admin/common.js

  5. I cleared cache/cookies, used different browsers, JavaScript enabled, tried different computers

The JavaScript code does not work at all. I viewed source and it's not there.

<!-- BEGIN Tynt Script -->
<script type="text/javascript">
    if(document.location.protocol=='http:'){
        var Tynt=Tynt||[];Tynt.push('cAe5WESDOr4BZUacwqm_6r');Tynt.i={"ap":"Read more:"};
        (function(){var s=document.createElement('script');s.async="async";s.type="text/javascript";s.src='http://tcr.tynt.com/ti.js';var h=document.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);})();
    }
</script>
<!-- END Tynt Script -->
like image 395
fudgepuppy Avatar asked Oct 26 '25 03:10

fudgepuppy


1 Answers

Do not include <script> and </script> on the *.js page - it will be included as a separate JS file, not inline in the HTML page.

Note that you don't need $wgAllowUserJs for javascript pages in the MediaWiki namespace, only for ones in the User namespace. (There is a separate setting called $wgUseSiteJs for enabling scripts in the MediaWiki namespace, but it is on by default).

like image 59
Tgr Avatar answered Oct 27 '25 17:10

Tgr