User:Oh! Tea/Toggle VF.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/* Toggle VF
轉換條目為 VF (voice-friendly) 適合朗讀的版本,來自[[:en:User:P999/Toggle VF.js]],詳細使用方法請見[[:en:User:P999/Toggle VF]]
安裝:請複製「mw.loader.load( '/w/index.php?title=User:Austin Zhang/Toggle VF.js&action=raw&ctype=text/javascript' )// Backlink: [[User:Austin Zhang/Toggle VF.js]]」並貼到你的自訂 JavaScript 裡
*/
// timestamp 05 Aug 2020 1421
var currpgName = mw.config.get( 'wgPageName' );
var currURL = document.location.href;
var prntable = currURL.endsWith("&printable=yes");
var torf = prntable.toString();
var myFlag; // must be defined here
var currFlag;
function chkmyFlag() {
try{
currFlag=window.localStorage.getItem("myFlag");
} catch (e) {
}
if (currFlag=="VF" && torf=="true")
{
nullFlag();
dotogg();
}
}
chkmyFlag();
function nullFlag() {
try {
window.localStorage.setItem("myFlag", "null");
} catch(e) {
}
}
function setFlag() {
try {
window.localStorage.setItem("myFlag", "VF");
} catch (e) {
}
}
function clrFlag() {
try {
window.localStorage.clear();
} catch(e){
}
}
// Printable VF Button
mw.loader.using( 'mediawiki.util', function () {
$( document ).ready( function() {
var prntVF = mw.util.addPortletLink ( 'p-electronpdfservice-sidebar-portlet-heading', 'https://zh.wikipedia.org/w/index.php?title=' currpgName '&printable=yes', "可列印 VF", "p-VF", "用於列印的適合朗讀的版本[v]","v");
$( prntVF ).click( function() {
setFlag();
});
});
});
// Toggle VF Button
var next="center";
mw.loader.using( 'mediawiki.util', function () {
$( document ).ready( function() {
var ToggVF = mw.util.addPortletLink( "p-tb", "#", "轉換 VF", "t-Toggle VF","轉換為適合朗讀的格式[4]",'4');
// alert('next is: ' next);
$( ToggVF ).click( function() {
dotogg();
if (next=="center") {firstHeading.style.textAlign = "center";
$( ".Template-Fact" ).hide(); next="left"; }
else
{firstHeading.style.textAlign = "left";
$( ".Template-Fact" ).show(); next="center";}
} );
} );
} );
// = = = = = = = = = = = = = = = = = = = =
function dotogg() {
$( 'head' ).append( '<style type="text/css" media="screen, print">' ' ul { list-style: none; }' '</style>' );
$( "wgCoordinates" ).toggle();
$( ".mw-headline[id='References'] " ).toggle();
$( ".mw-jump-link" ).toggle();
$( ".reference" ).toggle();
$( "ol.references" ).toggle();
$( ".toc" ).toggle();
$( ".template" ).toggle();
$( ".Template-Fact" ).hide();
$( ".collapsible" ).hide();
$( ".navbox" ).toggle();
$( ".navbar" ).toggle();
$( ".thumb" ).toggle();
$( ".wikitable" ).toggle();
$( ".toccolours" ).toggle();
$( ".hatnote" ).toggle();
$( ".hlist" ).toggle();
$( ".mw-headline[id='External_Links'] " ).toggle();
$( ".external" ).toggle();
// $( ".external text").toggle();
// $( ".external.text" ).show(); // showing only Ext Links
//
$( ".ambox" ).toggle();
$( ".mbox" ).toggle();
$( ".ombox" ).toggle();
$( ".dmbox" ).toggle();
$( ".fmbox" ).toggle();
$( ".geobox" ).toggle();
$( ".messagebox" ).toggle();
$( ".warningbox" ).toggle();
$( ".sidebar" ).toggle();
$( ".infobox" ).toggle();
$( ".infobox.sisterproject" ).toggle();
$( ".infobox.subdivision" ).toggle();
$( ".dablink" ).toggle();
$( ".metadata" ).toggle();
$( ".editlink" ).toggle();
//
$( "#siteSub" ).toggle();
$( ".printfooter" ).toggle();
$( "#catlinks, .catlinks" ).toggle();
$( "#footer" ).toggle();
$( "#header" ).toggle();
$( ".image" ).toggle();
$( ".metadata" ).toggle();
$( ".protected" ).toggle();
$( ".boilerplate" ).toggle();
$( ".mw-editsection-bracket" ).toggle();
$( ".mw-editsection" ).toggle();
}
// ----------------------------------