适配1.39

master
落雨楓 2 years ago
parent e45688a629
commit ee3915fa73

@ -5,8 +5,8 @@ use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
class BlockQuoteTagHandler extends ExtensionTagHandler { class BlockQuoteTagHandler extends ExtensionTagHandler {
public function sourceToDom(ParsoidExtensionAPI $extApi, string $src, array $extArgs): \DOMDocument { public function sourceToDom(ParsoidExtensionAPI $extApi, string $src, array $extArgs) {
$content = $extApi->extTagToDOM( return $extApi->extTagToDOM(
$extArgs, $extArgs,
'', '',
$src, $src,
@ -17,15 +17,12 @@ class BlockQuoteTagHandler extends ExtensionTagHandler {
], ],
], ],
); );
return $content;
} }
public function getInnerWikitext(ParsoidExtensionAPI $extApi, \DOMElement $dom) { public function getInnerWikitext(ParsoidExtensionAPI $extApi, \DOMElement $dom) {
$wikiText = ''; $wikiText = '';
foreach($dom->childNodes as $child){ foreach($dom->childNodes as $child){
if($child instanceof \DOMText){ if($child instanceof \DOMText){
/** @type \DOMText $child */
$wikiText .= $child->nodeValue; $wikiText .= $child->nodeValue;
} else { } else {
$wikiText .= $extApi->domToWikitext([], $child); $wikiText .= $extApi->domToWikitext([], $child);

@ -90,14 +90,14 @@ HTML
$showAdsSidebar = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-sidebar'); $showAdsSidebar = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-sidebar');
$showAdsBottom = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-bottom'); $showAdsBottom = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-bottom');
// 检测Adblock
$outputPage->addHeadItem('adblock-detect', '<script src="/peel1.js"></script>');
if($wgIsekaiShowAds if($wgIsekaiShowAds
&& ($showAdsSidebar || $showAdsBottom) && ($showAdsSidebar || $showAdsBottom)
&& $outputPage->getTitle()->getNamespace() !== NS_SPECIAL && $outputPage->getTitle()->getNamespace() !== NS_SPECIAL
&& $isView){ && $isView){
// 检测Adblock
$outputPage->addHeadItem('adblock-detect', '<script src="/peel1.js"></script>');
// 谷歌广告 // 谷歌广告
$outputPage->addHeadItem( $outputPage->addHeadItem(
'googlead', 'googlead',
@ -155,7 +155,7 @@ HTML
$title = $outputPage->getTitle(); $title = $outputPage->getTitle();
if ($title->inNamespace(NS_USER)) { if ($title->inNamespace(NS_USER)) {
$userName = $title->getText(); $userName = $title->getText();
$user = User::newFromName($userName); $user = MediaWikiServices::getInstance()->getUserFactory()->newFromName($userName);
if ($user && $user->isRegistered()) { if ($user && $user->isRegistered()) {
$showName = $user->getRealName(); $showName = $user->getRealName();
if (!$showName) { if (!$showName) {
@ -204,7 +204,7 @@ HTML
) { ) {
if ($target->inNamespace(NS_USER)) { if ($target->inNamespace(NS_USER)) {
$userName = $target->getText(); $userName = $target->getText();
$user = User::newFromName($userName); $user = MediaWikiServices::getInstance()->getUserFactory()->newFromName($userName);
if ($user && $user->isRegistered()) { if ($user && $user->isRegistered()) {
$showName = $user->getRealName(); $showName = $user->getRealName();
if ($showName) { if ($showName) {

@ -6,6 +6,8 @@ use Html;
class IsekaiChart { class IsekaiChart {
/** /**
* @param \Parser &$parser * @param \Parser &$parser
* @return bool
* @throws \MWException
*/ */
public static function onParserSetup(&$parser) { public static function onParserSetup(&$parser) {
$parser->setHook('isekaichart', self::class . '::create'); $parser->setHook('isekaichart', self::class . '::create');
@ -23,7 +25,6 @@ class IsekaiChart {
switch ($args['type']) { switch ($args['type']) {
case 'radar': case 'radar':
return self::createRadar($input, $args, $parser, $frame); return self::createRadar($input, $args, $parser, $frame);
break;
} }
return '<span class="error">' . wfMessage("isekai-chart-unknow-type", $args['type'])->parse() . '</span>'; return '<span class="error">' . wfMessage("isekai-chart-unknow-type", $args['type'])->parse() . '</span>';
} }
@ -58,12 +59,13 @@ class IsekaiChart {
/** /**
* @param string $input * @param string $input
* @param string[] $args * @param array $inputArgs
* @param \Parser $parser * @param \Parser $parser
* @param \PPFrame $frame * @param \PPFrame $frame
* @return string
*/ */
public static function createRadar(&$input, &$inputArgs, &$parser, &$frame) { public static function createRadar($input, &$inputArgs, $parser, $frame) {
$parser->getOutput()->addModules("ext.isekai.chart"); // 添加样式和脚本 $parser->getOutput()->addModules(["ext.isekai.chart"]); // 添加样式和脚本
$allowedArgs = ['width', 'height', 'shape']; $allowedArgs = ['width', 'height', 'shape'];
$args = self::parseArgs($inputArgs, [ $args = self::parseArgs($inputArgs, [

@ -105,8 +105,18 @@
"desktop", "desktop",
"mobile" "mobile"
] ]
},
"ext.isekai.ve": {
"scripts": ["ext.isekai.ve.js"],
"targets": [
"desktop",
"mobile"
]
} }
}, },
"VisualEditorPluginModules": [
"ext.isekai.ve"
],
"ResourceFileModulePaths": { "ResourceFileModulePaths": {
"localBasePath": "modules", "localBasePath": "modules",
"remoteExtPath": "IsekaiMisc/modules" "remoteExtPath": "IsekaiMisc/modules"

@ -230,6 +230,7 @@ $(function(){
if (mw.config.get('wgIsekaiShowAds')) { if (mw.config.get('wgIsekaiShowAds')) {
setTimeout(function() { setTimeout(function() {
if ($('#ad-dec-7kVsyacCEKVGBLOiLVQ').length === 0) { if ($('#ad-dec-7kVsyacCEKVGBLOiLVQ').length === 0) {
console.log('广告似乎被屏蔽了', $('#ad-dec-7kVsyacCEKVGBLOiLVQ'));
if (shouldShowAdsPrompt()) { if (shouldShowAdsPrompt()) {
//显示广告引导框 //显示广告引导框
var cancelBtn = new OO.ui.ActionWidget({ var cancelBtn = new OO.ui.ActionWidget({
@ -326,5 +327,8 @@ $(function(){
window.addEventListener('beforeunload', function() { window.addEventListener('beforeunload', function() {
$('html').addClass('content-unloading'); $('html').addClass('content-unloading');
setTimeout(function() {
$('html').removeClass('content-unloading');
}, 5000);
}); });
}); });

@ -168,36 +168,6 @@ html.content-loaded body.skin-timeless {
} }
} }
@media screen and (min-width: 851px){
#user-tools {
#personal {
margin-left: 0;
padding-left: 0.5em;
h2 {
padding: 7px 0 20px 25px;
background-position: 0 6px;
/*margin-top: -3px;*/
span {
margin-top: 1px;
overflow: visible;
}
}
}
#personal-extra {
margin-top: 0.8em;
}
}
}
@media screen and (min-width: 1100px){
#mw-header #user-tools {
width: 10em;
}
}
@media screen and (min-width: 851px){ @media screen and (min-width: 851px){
#mw-footer .footer-places li { #mw-footer .footer-places li {
white-space: pre; white-space: pre;

@ -0,0 +1,34 @@
if (mw.config.get('skin') === "timeless") {
var veReadyTimer = null;
var veReady = false;
var isFloating = false;
function updateToolbar() {
if (!veReady) return;
if (window.innerWidth >= 851 && !isFloating) {
if (!isFloating) {
var headerContainer = document.getElementById("mw-header-container");
var headerHack = document.getElementById("mw-header-hack");
var offset = headerContainer.offsetHeight + headerHack.offsetHeight;
ve.init.target.toolbarScrollOffset = offset;
isFloating = true;
}
} else if (isFloating) {
ve.init.target.toolbarScrollOffset = 0;
isFloating = false;
}
}
function waitForVE() {
if (ve && ve.init && ve.init.target) {
veReady = true;
updateToolbar();
if (veReadyTimer) {
clearInterval(veReadyTimer);
}
}
}
veReadyTimer = setInterval(waitForVE, 500);
window.addEventListener('resize', updateToolbar, { passive: true });
}
Loading…
Cancel
Save