Site Notice
hello, world
Difference between revisions of "QuickGetWikiCode"
From Project-EPB Commons
Line 1: | Line 1: | ||
+ | <tabber>Normal= | ||
<pre>function getWikiCode() { | <pre>function getWikiCode() { | ||
var preUrl = location.href.split('/'); | var preUrl = location.href.split('/'); | ||
Line 30: | Line 31: | ||
} | } | ||
getWikiCode()</pre> | getWikiCode()</pre> | ||
− | + | |-|Browser= | |
<pre>javascript:function getWikiCode() { var preUrl = location.href.split('/'); preUrl = preUrl[0]+'/'+preUrl[1]+'/'+preUrl[2]+'/api.php'; var url = prompt('Wiki url?',preUrl); if (url == null) return; var title = prompt('Pagename?',wgPageName); if (title == null) return; $.ajax({ url: url, dataType: 'jsonp', type: 'post', data: { page: title, action: 'parse', prop: 'wikitext', format: 'json' }, success: function(result) { var wikitext; if (result.parse !== undefined) { wikitext = result.parse.wikitext['*']; } else { wikitext = '%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E8%AF%BB%E5%8F%96%E9%A1%B5%E9%9D%A2%E3%80%82' } alert(wikitext); console.info(wikitext); } }); } getWikiCode()</pre> | <pre>javascript:function getWikiCode() { var preUrl = location.href.split('/'); preUrl = preUrl[0]+'/'+preUrl[1]+'/'+preUrl[2]+'/api.php'; var url = prompt('Wiki url?',preUrl); if (url == null) return; var title = prompt('Pagename?',wgPageName); if (title == null) return; $.ajax({ url: url, dataType: 'jsonp', type: 'post', data: { page: title, action: 'parse', prop: 'wikitext', format: 'json' }, success: function(result) { var wikitext; if (result.parse !== undefined) { wikitext = result.parse.wikitext['*']; } else { wikitext = '%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E8%AF%BB%E5%8F%96%E9%A1%B5%E9%9D%A2%E3%80%82' } alert(wikitext); console.info(wikitext); } }); } getWikiCode()</pre> | ||
+ | </tabber> |
Revision as of 00:46, 17 October 2019
<tabber>Normal=
function getWikiCode() { var preUrl = location.href.split('/'); preUrl = preUrl[0]+'/'+preUrl[1]+'/'+preUrl[2]+'/api.php'; var url = prompt('Wiki url?',preUrl); if (url == null) return; var title = prompt('Pagename?',wgPageName); if (title == null) return; $.ajax({ url: url, dataType: 'jsonp', type: 'post', data: { page: title, action: 'parse', prop: 'wikitext', format: 'json' }, success: function(result) { var wikitext; if (result.parse !== undefined) { wikitext = result.parse.wikitext['*']; } else { wikitext = '错误:无法读取页面。' } alert(wikitext); console.info(wikitext); } }); } getWikiCode()
|-|Browser=
javascript:function getWikiCode() { var preUrl = location.href.split('/'); preUrl = preUrl[0]+'/'+preUrl[1]+'/'+preUrl[2]+'/api.php'; var url = prompt('Wiki url?',preUrl); if (url == null) return; var title = prompt('Pagename?',wgPageName); if (title == null) return; $.ajax({ url: url, dataType: 'jsonp', type: 'post', data: { page: title, action: 'parse', prop: 'wikitext', format: 'json' }, success: function(result) { var wikitext; if (result.parse !== undefined) { wikitext = result.parse.wikitext['*']; } else { wikitext = '%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E8%AF%BB%E5%8F%96%E9%A1%B5%E9%9D%A2%E3%80%82' } alert(wikitext); console.info(wikitext); } }); } getWikiCode()
</tabber>