MediaWiki:NotifyWhenCopy/code.js

/** * Notify When Copy ** Add license notify when visitor copy article contents ** Author: 机智的小鱼君 & Fandom dev wiki users * LOGs ** 18:06, August 24, 2019 (UTC): Beta post **/ $(function { function init(i18n) {

(new mw.Api).get({     action: 'query',      meta: 'allmessages',      ammessages: 'License-description',      amlang: mw.config.get('wgUserLanguage') || mw.config.get('wgContentLanguage')    }).done(function(data) {      var License = $('.license-description a').prop('outerHTML'),      LicenseDescriptionMsg = data.query.allmessages[0]['*'].replace('$1', License);

$(window).on('copy',     function {        new BannerNotification( i18n.msg('youCopiedArticle').escape + LicenseDescriptionMsg + ' ' + i18n.msg('indicateSource').escape +  + location.href + , 'warn').show;      }); });

} mw.hook('dev.i18n').add(function(i18no) {    i18no.loadMessages('NotifyWhenCopy').then(init);  }); importArticle({   type: 'script',    article: 'u:dev:MediaWiki:I18n-js/code.js'  }); });