diff --git a/BlockQuoteTagHandler.class.php b/BlockQuoteTagHandler.class.php
index dd53f6c..fc709ae 100644
--- a/BlockQuoteTagHandler.class.php
+++ b/BlockQuoteTagHandler.class.php
@@ -5,8 +5,8 @@ use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
class BlockQuoteTagHandler extends ExtensionTagHandler {
- public function sourceToDom(ParsoidExtensionAPI $extApi, string $src, array $extArgs): \DOMDocument {
- $content = $extApi->extTagToDOM(
+ public function sourceToDom(ParsoidExtensionAPI $extApi, string $src, array $extArgs) {
+ return $extApi->extTagToDOM(
$extArgs,
'',
$src,
@@ -17,15 +17,12 @@ class BlockQuoteTagHandler extends ExtensionTagHandler {
],
],
);
-
- return $content;
}
public function getInnerWikitext(ParsoidExtensionAPI $extApi, \DOMElement $dom) {
$wikiText = '';
foreach($dom->childNodes as $child){
if($child instanceof \DOMText){
- /** @type \DOMText $child */
$wikiText .= $child->nodeValue;
} else {
$wikiText .= $extApi->domToWikitext([], $child);
diff --git a/Isekai.class.php b/Isekai.class.php
index c5ca54e..2e50231 100644
--- a/Isekai.class.php
+++ b/Isekai.class.php
@@ -90,13 +90,13 @@ HTML
$showAdsSidebar = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-sidebar');
$showAdsBottom = $service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'isekai-show-ads-bottom');
+ // 检测Adblock
+ $outputPage->addHeadItem('adblock-detect', '');
+
if($wgIsekaiShowAds
&& ($showAdsSidebar || $showAdsBottom)
&& $outputPage->getTitle()->getNamespace() !== NS_SPECIAL
&& $isView){
-
- // 检测Adblock
- $outputPage->addHeadItem('adblock-detect', '');
// 谷歌广告
$outputPage->addHeadItem(
@@ -155,7 +155,7 @@ HTML
$title = $outputPage->getTitle();
if ($title->inNamespace(NS_USER)) {
$userName = $title->getText();
- $user = User::newFromName($userName);
+ $user = MediaWikiServices::getInstance()->getUserFactory()->newFromName($userName);
if ($user && $user->isRegistered()) {
$showName = $user->getRealName();
if (!$showName) {
@@ -204,7 +204,7 @@ HTML
) {
if ($target->inNamespace(NS_USER)) {
$userName = $target->getText();
- $user = User::newFromName($userName);
+ $user = MediaWikiServices::getInstance()->getUserFactory()->newFromName($userName);
if ($user && $user->isRegistered()) {
$showName = $user->getRealName();
if ($showName) {
diff --git a/IsekaiChart.class.php b/IsekaiChart.class.php
index aaa2c1e..38ed701 100644
--- a/IsekaiChart.class.php
+++ b/IsekaiChart.class.php
@@ -6,6 +6,8 @@ use Html;
class IsekaiChart {
/**
* @param \Parser &$parser
+ * @return bool
+ * @throws \MWException
*/
public static function onParserSetup(&$parser) {
$parser->setHook('isekaichart', self::class . '::create');
@@ -23,7 +25,6 @@ class IsekaiChart {
switch ($args['type']) {
case 'radar':
return self::createRadar($input, $args, $parser, $frame);
- break;
}
return '' . wfMessage("isekai-chart-unknow-type", $args['type'])->parse() . '';
}
@@ -58,12 +59,13 @@ class IsekaiChart {
/**
* @param string $input
- * @param string[] $args
+ * @param array $inputArgs
* @param \Parser $parser
* @param \PPFrame $frame
+ * @return string
*/
- public static function createRadar(&$input, &$inputArgs, &$parser, &$frame) {
- $parser->getOutput()->addModules("ext.isekai.chart"); // 添加样式和脚本
+ public static function createRadar($input, &$inputArgs, $parser, $frame) {
+ $parser->getOutput()->addModules(["ext.isekai.chart"]); // 添加样式和脚本
$allowedArgs = ['width', 'height', 'shape'];
$args = self::parseArgs($inputArgs, [
diff --git a/extension.json b/extension.json
index 8021c80..9b87954 100644
--- a/extension.json
+++ b/extension.json
@@ -105,8 +105,18 @@
"desktop",
"mobile"
]
+ },
+ "ext.isekai.ve": {
+ "scripts": ["ext.isekai.ve.js"],
+ "targets": [
+ "desktop",
+ "mobile"
+ ]
}
},
+ "VisualEditorPluginModules": [
+ "ext.isekai.ve"
+ ],
"ResourceFileModulePaths": {
"localBasePath": "modules",
"remoteExtPath": "IsekaiMisc/modules"
diff --git a/modules/ext.isekai.js b/modules/ext.isekai.js
index 32d1ef0..507d987 100644
--- a/modules/ext.isekai.js
+++ b/modules/ext.isekai.js
@@ -230,6 +230,7 @@ $(function(){
if (mw.config.get('wgIsekaiShowAds')) {
setTimeout(function() {
if ($('#ad-dec-7kVsyacCEKVGBLOiLVQ').length === 0) {
+ console.log('广告似乎被屏蔽了', $('#ad-dec-7kVsyacCEKVGBLOiLVQ'));
if (shouldShowAdsPrompt()) {
//显示广告引导框
var cancelBtn = new OO.ui.ActionWidget({
@@ -326,5 +327,8 @@ $(function(){
window.addEventListener('beforeunload', function() {
$('html').addClass('content-unloading');
+ setTimeout(function() {
+ $('html').removeClass('content-unloading');
+ }, 5000);
});
});
\ No newline at end of file
diff --git a/modules/ext.isekai.less b/modules/ext.isekai.less
index dea140c..56bde55 100644
--- a/modules/ext.isekai.less
+++ b/modules/ext.isekai.less
@@ -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){
#mw-footer .footer-places li {
white-space: pre;
diff --git a/modules/ext.isekai.ve.js b/modules/ext.isekai.ve.js
new file mode 100644
index 0000000..a65a123
--- /dev/null
+++ b/modules/ext.isekai.ve.js
@@ -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 });
+}
\ No newline at end of file