diff --git a/Isekai.class.php b/Isekai.class.php
index 51a362b..c5ca54e 100644
--- a/Isekai.class.php
+++ b/Isekai.class.php
@@ -3,6 +3,7 @@
namespace Isekai;
use MediaWiki\MediaWikiServices;
+use Config;
use OutputPage;
use Html;
use Title;
@@ -12,169 +13,256 @@ use User;
use EditPage;
class Isekai {
- public static function onLoad($output) {
- $title = $output->getTitle();
+ public static function onLoad($output) {
+ $title = $output->getTitle();
- self::setHeader($output);
+ self::setHeader($output);
- if ($title->inNamespace(NS_USER)) {
- self::onUserPage($output);
- }
- }
+ if ($title->inNamespace(NS_USER)) {
+ self::onUserPage($output);
+ }
+ }
+
+ public static function setHeader(OutputPage $outputPage) {
+ $outputPage->addHeadItem('dns-prefetch-main', Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//www.isekai.cn']));
+ $outputPage->addHeadItem('sitemap-link', Html::element('link', [
+ 'rel' => 'sitemap', 'type' => 'application/xml',
+ 'title' => 'Sitemap', 'href' => '/sitemap/sitemap-index-wiki.xml',
+ ]));
+ // $outputPage->addHeadItem('dns-prefetch-static', \Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//static-www.isekai.cn']));
+
+ $outputPage->addMeta('robots', 'all');
+ $outputPage->addMeta('revisit-after', '1 days');
+ $outputPage->addMeta('author', '异世界百科');
+
+ $outputPage->addModuleStyles('ext.isekai.styles');
+ $outputPage->addModules('ext.isekai');
+ $outputPage->addModules('ext.fontawesome');
+ //$outputPage->addModules('ext.treeview');
- public static function setHeader(OutputPage $outputPage) {
- $outputPage->addHeadItem('dns-prefetch-main', Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//www.isekai.cn']));
- $outputPage->addHeadItem('sitemap-link', Html::element('link', [
- 'rel' => 'sitemap', 'type' => 'application/xml',
- 'title' => 'Sitemap', 'href' => '/sitemap/sitemap-index-wiki.xml',
- ]));
- // $outputPage->addHeadItem('dns-prefetch-static', \Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//static-www.isekai.cn']));
-
- $outputPage->addMeta('robots', 'all');
- $outputPage->addMeta('revisit-after', '1 days');
- $outputPage->addMeta('author', '异世界百科');
-
- $outputPage->addModuleStyles('ext.isekai.styles');
- $outputPage->addModules('ext.isekai');
- $outputPage->addModules('ext.fontawesome');
- //$outputPage->addModules('ext.treeview');
-
- // 加载动画,三秒内未加载完成则强制显示
- if ($outputPage->getSkin()->getSkinName() === 'timeless') {
- $outputPage->addHeadItem(
- 'loading-animate-script',
- <<getSkin()->getSkinName() === 'timeless') {
+ $outputPage->addHeadItem(
+ 'loading-animate-script',
+ <<
- var c = document.documentElement.classList;
- c.add('content-loading');
- setTimeout(function() {
- c.remove('content-loading');
- c.add('content-loaded');
- }, 3000);
- document.addEventListener('DOMContentLoaded', function() {
- var b = getComputedStyle(document.body, null).backgroundColor;
- var a = document.createElement('div');
- a.classList.add('page-loading-spinner');
- a.innerHTML = '
';
- document.body.appendChild(a);
- });
+ var c = document.documentElement.classList;
+ c.add('content-loading');
+ setTimeout(function() {
+ c.remove('content-loading');
+ c.add('content-loaded');
+ }, 3000);
+ document.addEventListener('DOMContentLoaded', function() {
+ var b = getComputedStyle(document.body, null).backgroundColor;
+ var a = document.createElement('div');
+ a.classList.add('page-loading-spinner');
+ a.innerHTML = '';
+ document.body.appendChild(a);
+ });
HTML
- );
- }
+ );
+ }
- // 百度统计
- $outputPage->addHeadItem(
- 'baiduhm',
- <<addHeadItem(
+ 'baiduhm',
+ <<
var _hmt = _hmt || [];
(function() {
- var hm = document.createElement("script");
- hm.src = "https://hm.baidu.com/hm.js?2f650f34db6f2bbffa0af4d4e91a09a9";
- var s = document.getElementsByTagName("script")[0];
- s.parentNode.insertBefore(hm, s);
+ var hm = document.createElement("script");
+ hm.src = "https://hm.baidu.com/hm.js?2f650f34db6f2bbffa0af4d4e91a09a9";
+ var s = document.getElementsByTagName("script")[0];
+ s.parentNode.insertBefore(hm, s);
})();
HTML
- );
- }
+ );
- public static function onUserPage(OutputPage $outputPage) {
- // 用户页
- $title = $outputPage->getTitle();
- if ($title->inNamespace(NS_USER)) {
- $userName = $title->getText();
- $user = User::newFromName($userName);
- if ($user && $user->isRegistered()) {
- $showName = $user->getRealName();
- if (!$showName) {
- $showName = $userName;
- }
- $outputPage->setPageTitle($showName);
- $outputPage->setSubtitle('@' . $title->getText());
- $outputPage->setHTMLTitle(wfMessage('group-user')->text() . ' - ' . $outputPage->getHTMLTitle());
- }
- }
- }
+ self::showAds($outputPage);
+ }
- public static function onSkinTemplateOutputPageBeforeExec(\SkinTemplate &$skin, \QuickTemplate &$template) {
- if (!$skin->getOutput()->isArticle()) return;
- $title = $skin->getTitle();
- if ($title && $title->isSubpage()) {
- //更改显示的标题
- $titleText = $template->get('title');
- if ($titleText) {
- $template->set('title', basename($titleText));
- }
- //面包屑
- $titlePathList = explode('/', $titleText);
- $titlePathLen = count($titlePathList);
- $breadcrumbsHtml = [
- Html::openElement('ol', ['class' => 'breadcrumb']),
- ];
- $linkRender = MediaWikiServices::getInstance()->getLinkRenderer();
- foreach ($titlePathList as $key => $titleName) {
- if ($key === $titlePathLen - 1) {
- $breadcrumbsHtml[] = Html::element('li', ['class' => 'active'], $titleName);
- } else {
- $titleSubPath = implode('/', array_slice($titlePathList, 0, $key + 1));
- $breadcrumbsHtml[] = Html::openElement('li') .
- $linkRender->makeLink(Title::newFromText($titleSubPath), $titleName) . Html::closeElement('li');
- }
- }
- $breadcrumbsHtml[] = Html::closeElement('ol');
- $template->extend('subtitle', implode($breadcrumbsHtml));
- }
- }
+ public static function showAds(OutputPage $outputPage) {
+ global $wgIsekaiShowAds;
+ $service = MediaWikiServices::getInstance();
+ $isView = $outputPage->getContext()->getRequest()->getText( 'action', 'view' ) == 'view';
+ $showAdsSidebar = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-sidebar');
+ $showAdsBottom = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-bottom');
- public static function onHtmlPageLinkRendererBegin(
- LinkRenderer $linkRenderer, LinkTarget $target,
- &$text, &$extraAttribs, &$query, &$ret
- ) {
- if ($target->inNamespace(NS_USER)) {
- $userName = $target->getText();
- $user = User::newFromName($userName);
- if ($user && $user->isRegistered()) {
- $showName = $user->getRealName();
- if ($showName) {
- $text = $showName;
- }
- }
- }
- }
+ if($wgIsekaiShowAds
+ && ($showAdsSidebar || $showAdsBottom)
+ && $outputPage->getTitle()->getNamespace() !== NS_SPECIAL
+ && $isView){
+
+ // 检测Adblock
+ $outputPage->addHeadItem('adblock-detect', '');
+
+ // 谷歌广告
+ $outputPage->addHeadItem(
+ 'googlead',
+ <<
+HTML
+ );
+
+ if ($showAdsSidebar && $outputPage->getSkin()->getSkinName() === 'timeless') {
+ $outputPage->addHTML(
+ <<
+ if (window.innerWidth >= 1100) {
+ var adElem = document.createElement('div');
+ adElem.className = 'googlead-container googlead-container-sidebar';
+ adElem.innerHTML = '';
+ var relatedNav = document.querySelector('#mw-related-navigation');
+ if (relatedNav) {
+ relatedNav.appendChild(adElem);
+ (adsbygoogle = window.adsbygoogle || []).push({});
+ }
+ }
+
+HTML
+ );
+ }
+
+ if ($showAdsBottom) {
+ $outputPage->addHTML(
+ <<
+
+
+HTML
+ );
+
+ $outputPage->addHTML(
+ <<
+ (adsbygoogle = window.adsbygoogle || []).push({});
+
+HTML
+ );
+ }
+ }
+ }
+
+ public static function onUserPage(OutputPage $outputPage) {
+ // 用户页
+ $title = $outputPage->getTitle();
+ if ($title->inNamespace(NS_USER)) {
+ $userName = $title->getText();
+ $user = User::newFromName($userName);
+ if ($user && $user->isRegistered()) {
+ $showName = $user->getRealName();
+ if (!$showName) {
+ $showName = $userName;
+ }
+ $outputPage->setPageTitle($showName);
+ $outputPage->setSubtitle('@' . $title->getText());
+ $outputPage->setHTMLTitle(wfMessage('group-user')->text() . ' - ' . $outputPage->getHTMLTitle());
+ }
+ }
+ }
+
+ public static function onSkinTemplateOutputPageBeforeExec(\SkinTemplate &$skin, \QuickTemplate &$template) {
+ if (!$skin->getOutput()->isArticle()) return;
+ $title = $skin->getTitle();
+ if ($title && $title->isSubpage()) {
+ //更改显示的标题
+ $titleText = $template->get('title');
+ if ($titleText) {
+ $template->set('title', basename($titleText));
+ }
+ //面包屑
+ $titlePathList = explode('/', $titleText);
+ $titlePathLen = count($titlePathList);
+ $breadcrumbsHtml = [
+ Html::openElement('ol', ['class' => 'breadcrumb']),
+ ];
+ $linkRender = MediaWikiServices::getInstance()->getLinkRenderer();
+ foreach ($titlePathList as $key => $titleName) {
+ if ($key === $titlePathLen - 1) {
+ $breadcrumbsHtml[] = Html::element('li', ['class' => 'active'], $titleName);
+ } else {
+ $titleSubPath = implode('/', array_slice($titlePathList, 0, $key + 1));
+ $breadcrumbsHtml[] = Html::openElement('li') .
+ $linkRender->makeLink(Title::newFromText($titleSubPath), $titleName) . Html::closeElement('li');
+ }
+ }
+ $breadcrumbsHtml[] = Html::closeElement('ol');
+ $template->extend('subtitle', implode($breadcrumbsHtml));
+ }
+ }
+
+ public static function onHtmlPageLinkRendererBegin(
+ LinkRenderer $linkRenderer, LinkTarget $target,
+ &$text, &$extraAttribs, &$query, &$ret
+ ) {
+ if ($target->inNamespace(NS_USER)) {
+ $userName = $target->getText();
+ $user = User::newFromName($userName);
+ if ($user && $user->isRegistered()) {
+ $showName = $user->getRealName();
+ if ($showName) {
+ $text = $showName;
+ }
+ }
+ }
+ }
+
+ public static function onAttemptSave(EditPage $editPage) {
+ $services = MediaWikiServices::getInstance();
+ $title = $editPage->getTitle();
+ if (
+ !$title || !$title->inNamespace(NS_MAIN) ||
+ !$title->isSubpage() || $title->exists()
+ ) {
+ return true;
+ }
+ $path = explode('/', $title->getBaseText());
+ $categoryList = [];
+ $pathLen = count($path);
+ for ($i = 0; $i < $pathLen; $i ++) {
+ if ($i === 0) {
+ $categoryList[] = $path[0];
+ } else {
+ $categoryList[] = implode('/', array_slice($path, 0, $i + 1));
+ }
+ }
+
+ $categorySyntaxList = [];
+ $categoryNsText = $services->getContentLanguage()->
+ getNsText($services->getNamespaceInfo()->getSubject(NS_CATEGORY));
+ foreach ($categoryList as $categoryName) {
+ $categorySyntaxList[] = "[[{$categoryNsText}:{$categoryName}]]";
+ }
+ if (substr($editPage->textbox1, -1, 1) !== "\n") {
+ $editPage->textbox1 .= "\n" . implode("", $categorySyntaxList);
+ } else {
+ $editPage->textbox1 .= implode("", $categorySyntaxList);
+ }
+ return true;
+ }
+
+ public static function onResourceLoaderGetConfigVars(array &$vars, string $skin, Config $config){
+ $vars['wgIsekaiShowAds'] = $config->get('IsekaiShowAds');
+ }
+
+ public static function onGetPreferences(User $user, array &$preferences){
+ $preferences['isekai-show-ads-bottom'] = [
+ 'type' => 'toggle',
+ 'label-message' => 'isekai-show-ads-bottom',
+ 'section' => 'misc/isekai-ads',
+ ];
- public static function onAttemptSave(EditPage $editPage) {
- $services = MediaWikiServices::getInstance();
- $title = $editPage->getTitle();
- if (
- !$title || !$title->inNamespace(NS_MAIN) ||
- !$title->isSubpage() || $title->exists()
- ) {
- return true;
- }
- $path = explode('/', $title->getBaseText());
- $categoryList = [];
- $pathLen = count($path);
- for ($i = 0; $i < $pathLen; $i ++) {
- if ($i === 0) {
- $categoryList[] = $path[0];
- } else {
- $categoryList[] = implode('/', array_slice($path, 0, $i + 1));
- }
- }
-
- $categorySyntaxList = [];
- $categoryNsText = $services->getContentLanguage()->
- getNsText($services->getNamespaceInfo()->getSubject(NS_CATEGORY));
- foreach ($categoryList as $categoryName) {
- $categorySyntaxList[] = "[[{$categoryNsText}:{$categoryName}]]";
- }
- if (substr($editPage->textbox1, -1, 1) !== "\n") {
- $editPage->textbox1 .= "\n" . implode("", $categorySyntaxList);
- } else {
- $editPage->textbox1 .= implode("", $categorySyntaxList);
- }
- return true;
+ $preferences['isekai-show-ads-sidebar'] = [
+ 'type' => 'toggle',
+ 'label-message' => 'isekai-show-ads-sidebar',
+ 'section' => 'misc/isekai-ads',
+ ];
}
}
diff --git a/extension.json b/extension.json
index 52df857..8021c80 100644
--- a/extension.json
+++ b/extension.json
@@ -11,7 +11,7 @@
},
"MessagesDirs": {
- "Isekai": [
+ "IsekaiMisc": [
"i18n"
]
},
@@ -37,6 +37,12 @@
"HtmlPageLinkRendererBegin": [
"Isekai\\Isekai::onHtmlPageLinkRendererBegin"
],
+ "ResourceLoaderGetConfigVars": [
+ "Isekai\\Isekai::onResourceLoaderGetConfigVars"
+ ],
+ "GetPreferences": [
+ "Isekai\\Isekai::onGetPreferences"
+ ],
"EditPage::attemptSave": [
"Isekai\\Isekai::onAttemptSave"
]
@@ -63,6 +69,9 @@
"isekai-login-prompt-btn-login",
"isekai-login-prompt-btn-createaccount",
"isekai-login-prompt-btn-cancel",
+ "isekai-ads-prompt-title",
+ "isekai-ads-prompt-content",
+ "isekai-ads-prompt-btn-cancel",
"nav-login-createaccount"
]
},
@@ -100,7 +109,14 @@
},
"ResourceFileModulePaths": {
"localBasePath": "modules",
- "remoteExtPath": "Isekai/modules"
+ "remoteExtPath": "IsekaiMisc/modules"
+ },
+ "DefaultUserOptions": {
+ "isekai-show-ads-bottom": true,
+ "isekai-show-ads-sidebar": true
},
+ "config": {
+ "IsekaiShowAds": false
+ },
"manifest_version": 1
}
\ No newline at end of file
diff --git a/i18n/en.json b/i18n/en.json
index c1e9707..cb585ca 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,5 +8,27 @@
"isekai-login-prompt-content": "Share your imagine world, contribute your fictional settings, and help more people! now, let's join the Fantasy World wiki.",
"isekai-login-prompt-btn-login": "Login",
"isekai-login-prompt-btn-createaccount": "Create Account",
- "isekai-login-prompt-btn-cancel": "Cancel"
+ "isekai-login-prompt-btn-cancel": "Cancel",
+
+ "isekai-background-param-error": "Background image parameter error: ",
+
+ "isekai-editor-prompt-content": "Please select the editor, use the Standard Editor will get a better writing experience.",
+ "isekai-editor-prompt-btn-cancel": "Cancel",
+ "isekai-editor-prompt-btn-use-mobile": "Mobile Editor",
+ "isekai-editor-prompt-btn-use-desktop": "Standard Editor",
+
+ "isekai-userpage": "User",
+
+ "isekai-chart-undefined-type": "Undefined chart type",
+ "isekai-chart-unknow-type": "Unknow chart type: {0}",
+ "isekai-chart-transform-error": "Data conversion errors: {0}",
+ "isekai-chart-default-row-name": "Data {0}",
+
+ "prefs-isekai-ads": "Support Fanta World Wiki",
+ "isekai-show-ads-bottom": "Display ads at the bottom of the content page",
+ "isekai-show-ads-sidebar": "Display ads in the sidebar of the PC version",
+
+ "isekai-ads-prompt-title": "Please allow ads on Fanta World Wiki",
+ "isekai-ads-prompt-content": "Looks like you're using an ad blocker.
Fanta World Wiki rely on advertising to help fund our site.
If you want to support Fanta World Wiki, you can turn off Adblock, Adblock Pro, and other plugins on this site.
",
+ "isekai-ads-prompt-btn-cancel": "No longer display"
}
\ No newline at end of file
diff --git a/i18n/zh-hans.json b/i18n/zh-hans.json
index d7db86e..d33343b 100644
--- a/i18n/zh-hans.json
+++ b/i18n/zh-hans.json
@@ -9,6 +9,7 @@
"isekai-login-prompt-btn-login": "登录",
"isekai-login-prompt-btn-createaccount": "创建账户",
"isekai-login-prompt-btn-cancel": "残忍拒绝",
+
"isekai-background-param-error": "背景图片参数错误:",
"isekai-editor-prompt-content": "请选择编辑器,使用完整版编辑器可以获得更好的体验",
@@ -21,5 +22,13 @@
"isekai-chart-undefined-type": "未定义图表类型",
"isekai-chart-unknow-type": "未知的图表类型:{0}",
"isekai-chart-transform-error": "数据转换错误:{0}",
- "isekai-chart-default-row-name": "数据 {0}"
+ "isekai-chart-default-row-name": "数据 {0}",
+
+ "prefs-isekai-ads": "支持异世界百科",
+ "isekai-show-ads-bottom": "在页面底部显示广告",
+ "isekai-show-ads-sidebar": "在PC版侧栏显示广告",
+
+ "isekai-ads-prompt-title": "您似乎屏蔽了广告",
+ "isekai-ads-prompt-content": "目前,页面广告是异世界百科的唯一收入来源。
如果您想要支持异世界百科,可以在此站点上关闭Adblock、Adblock Pro等插件。
如果想要移除广告空位,可以在用户-参数设置中关闭广告。
",
+ "isekai-ads-prompt-btn-cancel": "不再显示"
}
\ No newline at end of file
diff --git a/i18n/zh-hant.json b/i18n/zh-hant.json
index aae06db..d520500 100644
--- a/i18n/zh-hant.json
+++ b/i18n/zh-hant.json
@@ -9,6 +9,7 @@
"isekai-login-prompt-btn-login": "登錄",
"isekai-login-prompt-btn-createaccount": "創建賬號",
"isekai-login-prompt-btn-cancel": "關閉",
+
"isekai-background-param-error": "背景圖片參數錯誤:",
"isekai-editor-prompt-content": "請選擇編輯器,使用完整版編輯器可以獲得更好的體驗",
@@ -21,5 +22,13 @@
"isekai-chart-undefined-type": "未定義圖表類型",
"isekai-chart-unknow-type": "未知的圖表類型:{0}",
"isekai-chart-transform-error": "資料轉換錯誤:{0}",
- "isekai-chart-default-row-name": "資料 {0}"
+ "isekai-chart-default-row-name": "資料 {0}",
+
+ "prefs-isekai-ads": "支持異世界百科",
+ "isekai-show-ads-bottom": "在頁面底部顯示廣告",
+ "isekai-show-ads-sidebar": "在PC版側欄顯示廣告",
+
+ "isekai-ads-prompt-title": "您似乎屏蔽了廣告",
+ "isekai-ads-prompt-content": "目前,頁面廣告是異世界百科的唯一收入來源。
如果您想要支持異世界百科,可以在此網站上關閉Adblock、Adblock Pro等擴展程式。
如果想要移除廣告空位,可以在用戶-參數設置中關閉廣告。
",
+ "isekai-ads-prompt-btn-cancel": "不再顯示"
}
\ No newline at end of file
diff --git a/modules/ext.isekai.js b/modules/ext.isekai.js
index 87e9d65..32d1ef0 100644
--- a/modules/ext.isekai.js
+++ b/modules/ext.isekai.js
@@ -57,14 +57,14 @@ function getPageVisited(){
}
}
-function setDismiss(){
+function setDismissLoginPrompt(){
var time = Date.now() / 1000;
localStorage.setItem('dismissLoginPrompt', time.toFixed(0));
}
-function shouldShowPrompt(){
+function shouldShowLoginPrompt(){
if(!mw.user.isAnon()){ //用户已登录
- setDismiss();
+ setDismissLoginPrompt();
return false;
}
@@ -90,6 +90,29 @@ function shouldShowPrompt(){
return true;
}
+function setDismissAdsPrompt(){
+ var time = Date.now() / 1000;
+ localStorage.setItem('dismissAdsPrompt', time.toFixed(0));
+}
+
+function shouldShowAdsPrompt(){
+ if(mw.config.get('wgCanonicalNamespace') === 'Special' && mw.config.get('wgAction') === 'view'){ // 仅查看页面弹出
+ return false;
+ }
+
+ var time = Date.now() / 1000;
+ var expire = 86400 * 7; //7天内不提醒
+ var dismissTime = localStorage.getItem('dismissAdsPrompt');
+ if(dismissTime !== null){
+ dismissTime = parseInt(dismissTime);
+ if(dismissTime + expire > time){
+ return false;
+ }
+ }
+
+ return true;
+}
+
$(function(){
//锚链接偏移
$('body').on('click', 'a', function() {
@@ -122,6 +145,8 @@ $(function(){
// 初始化dialog
var messageDialog = new OO.ui.MessageDialog();
var windowManager = new OO.ui.WindowManager();
+ window._isekaiMessageDialog = messageDialog;
+ window._isekaiWindowManager = windowManager;
$('body').append(windowManager.$element);
windowManager.addWindows([messageDialog]);
@@ -164,43 +189,102 @@ $(function(){
}
//显示登录引导框
- var cancelBtn = new OO.ui.ActionWidget({
- action: 'cancel',
- label: mw.message('isekai-login-prompt-btn-cancel').text(),
- flags: ['safe', 'close'],
- });
-
- var registerBtn = new OO.ui.ActionWidget({
- action: 'register',
- label: mw.message('isekai-login-prompt-btn-createaccount').text(),
- });
-
- var loginBtn = new OO.ui.ActionWidget({
- action: 'login',
- active: true,
- label: mw.message('nav-login-createaccount').text(),
- flags: ['primary', 'progressive'],
- });
-
- cancelBtn.on('click', function(){
- setDismiss();
- });
-
- registerBtn.on('click', function(){
- location.href = mw.util.getUrl('Special:CreateAccount', {returnto: mw.config.get('wgPageName')});
- });
-
- loginBtn.on('click', function(){
- location.href = mw.util.getUrl('Special:Userlogin', {returnto: mw.config.get('wgPageName')});
- });
-
- if(shouldShowPrompt()){
+ if (shouldShowLoginPrompt()) {
+ var cancelBtn = new OO.ui.ActionWidget({
+ action: 'cancel',
+ label: mw.message('isekai-login-prompt-btn-cancel').text(),
+ flags: ['safe', 'close'],
+ });
+
+ var registerBtn = new OO.ui.ActionWidget({
+ action: 'register',
+ label: mw.message('isekai-login-prompt-btn-createaccount').text(),
+ });
+
+ var loginBtn = new OO.ui.ActionWidget({
+ action: 'login',
+ active: true,
+ label: mw.message('nav-login-createaccount').text(),
+ flags: ['primary', 'progressive'],
+ });
+
+ cancelBtn.on('click', function(){
+ setDismissLoginPrompt();
+ });
+
+ registerBtn.on('click', function(){
+ location.href = mw.util.getUrl('Special:CreateAccount', {returnto: mw.config.get('wgPageName')});
+ });
+
+ loginBtn.on('click', function(){
+ location.href = mw.util.getUrl('Special:Userlogin', {returnto: mw.config.get('wgPageName')});
+ });
+
windowManager.openWindow(messageDialog, {
message: mw.message('isekai-login-prompt-content').parse(),
actions: [cancelBtn, loginBtn], // 去除注册按钮
});
}
+ // 广告存活检测
+ if (mw.config.get('wgIsekaiShowAds')) {
+ setTimeout(function() {
+ if ($('#ad-dec-7kVsyacCEKVGBLOiLVQ').length === 0) {
+ if (shouldShowAdsPrompt()) {
+ //显示广告引导框
+ var cancelBtn = new OO.ui.ActionWidget({
+ action: 'cancel',
+ label: mw.message('isekai-ads-prompt-btn-cancel').text(),
+ active: true,
+ flags: ['safe', 'close'],
+ });
+
+ cancelBtn.on('click', function(){
+ setDismissAdsPrompt();
+ });
+
+ windowManager.openWindow(messageDialog, {
+ title: mw.message('isekai-ads-prompt-title').parse(),
+ message: '',
+ size: 'medium',
+ actions: [cancelBtn],
+ });
+ messageDialog.$body.find('> .oo-ui-messageDialog-container > .oo-ui-messageDialog-text > .oo-ui-messageDialog-message')
+ .append(mw.message('isekai-ads-prompt-content').parse());
+ }
+ }
+ }, 500);
+ }
+
+ /* 展示Google的Adblock提示,但是在大陆貌似没有用
+ if (mw.config.get('wgIsekaiShowAds')) {
+ window.googlefc = window.googlefc || {};
+ window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
+ googlefc.controlledMessagingFunction = (message) => {
+ if (shouldShowAdsPrompt()) {
+ message.proceed(true);
+ } else {
+ message.proceed(false);
+ }
+ };
+
+ function signalGooglefcPresent() {
+ if (!window.frames['googlefcPresent']) {
+ if (document.body) {
+ const iframe = document.createElement('iframe');
+ iframe.style = 'width: 0; height: 0; border: none; z-index: -1000; left: -1000px; top: -1000px;';
+ iframe.style.display = 'none';
+ iframe.name = 'googlefcPresent';
+ document.body.appendChild(iframe);
+ setDismissAdsPrompt();
+ } else {
+ window.requestAnimationFrame(signalGooglefcPresent);
+ }
+ }
+ }
+ signalGooglefcPresent();
+ }*/
+
// 显示用户头像
if(mw.config.get('wgNamespaceNumber') === 2 && mw.config.get('wgAvatarTemplate')) {
$('').insertAfter("#firstHeading");
@@ -213,6 +297,7 @@ $(function(){
userHeading.append(``);
}
+ // 更改ContentTranslation的机器翻译名字
if (mw.cx && mw.cx.MachineTranslationManager) {
let _getProviderLabel = mw.cx.MachineTranslationManager.prototype.getProviderLabel;
mw.cx.MachineTranslationManager.prototype.getProviderLabel = function ( provider ) {
diff --git a/modules/ext.isekai.less b/modules/ext.isekai.less
index 23bb71e..dea140c 100644
--- a/modules/ext.isekai.less
+++ b/modules/ext.isekai.less
@@ -270,4 +270,25 @@ html.content-loaded body.skin-timeless {
.oo-ui-messageDialog-actions-horizontal .oo-ui-actionWidget {
width: auto !important;
+}
+
+
+.googlead-container-bottom {
+ margin-top: 10px;
+ margin-bottom: 8px;
+ width: 100%;
+ min-height: 90px;
+}
+
+.skin-minerva .googlead-container-bottom {
+ margin-top: 30px;
+ margin-left: 16px;
+ margin-bottom: 16px;
+ margin-right: 16px;
+}
+
+@media screen and (max-width: 1099px) {
+ .googlead-container-sidebar {
+ display: none;
+ }
}
\ No newline at end of file