User:Twinzor/wikimark.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Twinzor/wikimark. |
//<nowiki>
//WikiMark
//
//A bookmarking tool for Wikipedia.
//
//By User:Twinzor on enwp.
//
//99% of the code is copied from other scripts on WP.
//
//If you improve my sloppy code, I would
//appreaciate it if you could drop me
//a line on my talkpage. Thanks!
//
//Reading configuration or setting defaults if not present:
if(typeof WikimarkConfigWikimarksPage == 'undefined') {
var wikimarkspage = "/WikiMarks";
}
else {
var wikimarkspage = "/"+WikimarkConfigWikimarksPage;
}
if(typeof WikimarkConfigListType == 'undefined') {
var listtype = "*";
}
else {
var listtype = WikimarkConfigListType;
}
if(typeof WikimarkConfigAddMenu == 'undefined') {
var addMenulocation = "p-cactions";
var menuPrefix = "ca-";
}
else if( WikimarkConfigAddMenu == "cactions" ) {
var addMenulocation = "p-cactions";
var menuPrefix = "ca-";
}
else if( WikimarkConfigAddMenu == "personal" ) {
var addMenulocation = "p-personal";
var menuPrefix = "pt-";
}
else if( WikimarkConfigAddMenu == "toolbox" ) {
var addMenulocation = "p-tb";
var menuPrefix = "t-";
}
else if( WikimarkConfigAddMenu == "navigation" ) {
var addMenulocation = "p-navigation";
var menuPrefix = "n-";
}
else {
var addMenulocation = "p-cactions";
var menuPrefix = "ca-";
}
if(typeof WikimarkConfigViewMenu == 'undefined') {
var viewMenulocation = "p-cactions";
var menuPrefixV = "ca-";
}
else if( WikimarkConfigViewMenu == "cactions" ) {
var viewMenulocation = "p-cactions";
var menuPrefixV = "ca-";
}
else if( WikimarkConfigViewMenu == "personal" ) {
var viewMenulocation = "p-personal";
var menuPrefixV = "pt-";
}
else if( WikimarkConfigViewMenu == "toolbox" ) {
var viewMenulocation = "p-tb";
var menuPrefixV = "t-";
}
else if( WikimarkConfigViewMenu == "navigation" ) {
var viewMenulocation = "p-navigation";
var menuPrefixV = "n-";
}
else {
var viewMenulocation = "p-cactions";
var menuPrefixV = "ca-";
}
var wikimarklinkprefix = wgServer+wgScript;
var wikimarkEncodedUserName = encodeURIComponent(wgUserName);
addOnloadHook(WikiMarkInit);
function WikiMarkInit () {
if(typeof WikimarkConfigViewNextTo == 'undefined') {
var viewNextto = '';
}
else {
var viewNextto = document.getElementById(menuPrefixV+WikimarkConfigViewNextTo);
}
if(typeof WikimarkConfigAddNextTo == 'undefined') {
var addNextto = '';
}
else {
var addNextto = document.getElementById(menuPrefix+WikimarkConfigAddNextTo);
}
addPortletLink (addMenulocation, 'javascript:doAddWikiMark()', 'WikiMark', menuPrefix+'addwikimark', 'WikiMark this page', '', addNextto);
addPortletLink (viewMenulocation, wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage, 'My WikiMarks', menuPrefixV+'showwikimark', 'Open your WikiMarks', '', viewNextto);
}
function doAddWikiMark () {
var wikimarkNewpage = wgPageName.replace(/_/g, " ");
if(wikimarkNewpage.indexOf("File:")==0) {
wikimarkNewpage = ":" + wikimarkNewpage;
}
var f;
f=document.createElement("IFRAME");
f.id="WikiMarksLoader";
f.onload=function() {
var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list. (Using [[User:Twinzor/Wikimark|WikiMark]])";
e=f.contentWindow.document.editform,e.wpTextbox1.value+=listtype+"["+"["+wikimarkNewpage+"]"+"]\n",e.wpSummary.value=wikimark_cmt,e.wpSave.click();
var iframe = document.getElementById('WikiMarksLoader');
jsMsg("'''"+wikimarkNewpage+"''' has been added to your WikiMarks.");
iframe.style.display="none";
};
f.src=wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit",document.body.appendChild(f);
};
// </nowiki>