更多操作
无编辑摘要 标签:手工回退 |
无编辑摘要 |
||
第1行: | 第1行: | ||
/*<%-- [PAGE_INFO] | |||
comment = #Please do not remove this struct. It's record contains some important information of edit. This struct will be removed automatically after you push edits.# | |||
pageTitle = #MediaWiki:Gadget-tikuShuaTi.js# | |||
pageID = #3486# | |||
revisionID = #68607# | |||
contentModel = #javascript# | |||
contentFormat = #text/javascript# | |||
[END_PAGE_INFO] --%>*/ | |||
// 添加刷题按钮 | |||
var title = $('#immerse_button').children('p').text() | var title = $('#immerse_button').children('p').text() | ||
$('<button class="button" onclick="window.open(\'https://www.medforest.cn/tools/tiku?title='+title+'\')">进入做题页面</button>').appendTo($('#immerse_button')) | $('<button class="button" onclick="window.open(\'https://www.medforest.cn/tools/tiku?title='+title+'\')">进入做题页面</button>').appendTo($('#immerse_button')) | ||
//添加到下一章节的按钮 | |||
//如果是题库名字空间再运行 | |||
if($('.mw-page-title-namespace').text === '题库'){ | |||
var thisPageName = $('.mw-page-title-main').text().split('/')[0] | |||
var indexName = '模板:目录-'+thisPageName | |||
getIndexPageWikiTextAndInsertButton(indexName) | |||
} | |||
// | |||
function getIndexPageWikiTextAndInsertButton(title){ | |||
var api = new mw.Api(); | |||
api.get( { | |||
"action": "query", | |||
"format": "json", | |||
"prop": "revisions", | |||
"titles": title, | |||
"utf8": 1, | |||
"rvprop": "content", | |||
"rvlimit": 1, | |||
"rvslots": "*", | |||
"rvdir": "older" | |||
} ).done( function ( data ) { | |||
console.log( data ); | |||
} ); | |||
} | |||
//解析目录项 | |||
//** {{目录项|题库:诊断学学习指导与习题集(第4版)/第一篇/第一节|第一节 发热}} | |||
function rIndex(text){ | |||
console.log(text) | |||
if(text.length>0){ | |||
var reg1 = new RegExp('(?<=\\{\\{目录项)(.+?)(?=\\}\\})','g') | |||
var reg2 = new RegExp('\\{\\{目录项(.+?)\\}\\}','g') | |||
var content = text.match(reg1)[0] | |||
text=text.replace(reg2,'') | |||
var level = text.match(/\*/g).length | |||
content = content.split('/').slice(-1) | |||
var finalText = '' | |||
for(var i=0;i<level;i++){ | |||
finalText+='*' | |||
} | |||
finalText+=' '+content+'\n' | |||
console.log(finalText) | |||
return finalText | |||
}else{ | |||
return '' | |||
} | |||
} |
2023年6月20日 (二) 09:42的版本
/*<%-- [PAGE_INFO]
comment = #Please do not remove this struct. It's record contains some important information of edit. This struct will be removed automatically after you push edits.#
pageTitle = #MediaWiki:Gadget-tikuShuaTi.js#
pageID = #3486#
revisionID = #68607#
contentModel = #javascript#
contentFormat = #text/javascript#
[END_PAGE_INFO] --%>*/
// 添加刷题按钮
var title = $('#immerse_button').children('p').text()
$('<button class="button" onclick="window.open(\'https://www.medforest.cn/tools/tiku?title='+title+'\')">进入做题页面</button>').appendTo($('#immerse_button'))
//添加到下一章节的按钮
//如果是题库名字空间再运行
if($('.mw-page-title-namespace').text === '题库'){
var thisPageName = $('.mw-page-title-main').text().split('/')[0]
var indexName = '模板:目录-'+thisPageName
getIndexPageWikiTextAndInsertButton(indexName)
}
//
function getIndexPageWikiTextAndInsertButton(title){
var api = new mw.Api();
api.get( {
"action": "query",
"format": "json",
"prop": "revisions",
"titles": title,
"utf8": 1,
"rvprop": "content",
"rvlimit": 1,
"rvslots": "*",
"rvdir": "older"
} ).done( function ( data ) {
console.log( data );
} );
}
//解析目录项
//** {{目录项|题库:诊断学学习指导与习题集(第4版)/第一篇/第一节|第一节 发热}}
function rIndex(text){
console.log(text)
if(text.length>0){
var reg1 = new RegExp('(?<=\\{\\{目录项)(.+?)(?=\\}\\})','g')
var reg2 = new RegExp('\\{\\{目录项(.+?)\\}\\}','g')
var content = text.match(reg1)[0]
text=text.replace(reg2,'')
var level = text.match(/\*/g).length
content = content.split('/').slice(-1)
var finalText = ''
for(var i=0;i<level;i++){
finalText+='*'
}
finalText+=' '+content+'\n'
console.log(finalText)
return finalText
}else{
return ''
}
}