完成谷歌广告功能

master
落雨楓 2 years ago
parent 246d1a7c3d
commit e45688a629

@ -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',
<<<HTML
// 加载动画,三秒内未加载完成则强制显示
if ($outputPage->getSkin()->getSkinName() === 'timeless') {
$outputPage->addHeadItem(
'loading-animate-script',
<<<HTML
<script type="text/javascript">
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 = '<div class="spinner-box"><div class="circle-border"><div class="circle-core" style="background-color: ' + b + '"></div></div></div>';
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 = '<div class="spinner-box"><div class="circle-border"><div class="circle-core" style="background-color: ' + b + '"></div></div></div>';
document.body.appendChild(a);
});
</script>
HTML
);
}
);
}
// 百度统计
$outputPage->addHeadItem(
'baiduhm',
<<<HTML
// 百度统计
$outputPage->addHeadItem(
'baiduhm',
<<<HTML
<script type="text/javascript">
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);
})();
</script>
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', '<script src="/peel1.js"></script>');
// 谷歌广告
$outputPage->addHeadItem(
'googlead',
<<<HTML
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8607817613161226" crossorigin="anonymous"></script>
HTML
);
if ($showAdsSidebar && $outputPage->getSkin()->getSkinName() === 'timeless') {
$outputPage->addHTML(
<<<HTML
<script type="text/javascript">
if (window.innerWidth >= 1100) {
var adElem = document.createElement('div');
adElem.className = 'googlead-container googlead-container-sidebar';
adElem.innerHTML = '<ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8607817613161226" data-ad-slot="8245595332" data-ad-format="rectangle" data-full-width-responsive="true"></ins>';
var relatedNav = document.querySelector('#mw-related-navigation');
if (relatedNav) {
relatedNav.appendChild(adElem);
(adsbygoogle = window.adsbygoogle || []).push({});
}
}
</script>
HTML
);
}
if ($showAdsBottom) {
$outputPage->addHTML(
<<<HTML
<div class="googlead-container googlead-container-bottom">
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-8607817613161226"
data-ad-slot="3245545943"
data-ad-format="horizontal"
data-full-width-responsive="true"></ins>
</div>
HTML
);
$outputPage->addHTML(
<<<HTML
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
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',
];
}
}

@ -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
}

@ -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": "<p>Looks like you're using an ad blocker.</p><p>Fanta World Wiki rely on advertising to help fund our site.</p><p>If you want to support Fanta World Wiki, you can turn off Adblock, Adblock Pro, and other plugins on this site.</p>",
"isekai-ads-prompt-btn-cancel": "No longer display"
}

@ -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": "<p>目前,页面广告是异世界百科的唯一收入来源。</p><p>如果您想要支持异世界百科可以在此站点上关闭Adblock、Adblock Pro等插件。</p><p>如果想要移除广告空位,可以在用户-参数设置中关闭广告。</p>",
"isekai-ads-prompt-btn-cancel": "不再显示"
}

@ -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": "<p>目前,頁面廣告是異世界百科的唯一收入來源。</p><p>如果您想要支持異世界百科可以在此網站上關閉Adblock、Adblock Pro等擴展程式。</p><p>如果想要移除廣告空位,可以在用戶-參數設置中關閉廣告。</p>",
"isekai-ads-prompt-btn-cancel": "不再顯示"
}

@ -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);
}
/* GoogleAdblock
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')) {
$('<div id="userHeading" class="user-heading"></div>').insertAfter("#firstHeading");
@ -213,6 +297,7 @@ $(function(){
userHeading.append(`<img src="${avatarUrl}" alt="${avatarAlt}" class="user-avatar">`);
}
// 更改ContentTranslation的机器翻译名字
if (mw.cx && mw.cx.MachineTranslationManager) {
let _getProviderLabel = mw.cx.MachineTranslationManager.prototype.getProviderLabel;
mw.cx.MachineTranslationManager.prototype.getProviderLabel = function ( provider ) {

@ -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;
}
}
Loading…
Cancel
Save