Jump to content

User:Gxnx0xmx0xn/personalgn0Marks.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// gn0Marks //
//
// A bookmarking tool for Wikipedia.
// Adapted (i.e., jury-rigged) in 2015 by User:Gxnx0xmx0xn on enwp from WikiMarks by User:Twinzor on enwp.
//
// See User:Gxnx0xmx0xn/gn0Marks for more info on installation.

// This is not the version for public release.
 
	//////////////////////////
	//						//
	//		gn0m0n.com		//
	//						//
	//////////////			//	
	//////////////			//	
	//////////////			//	
	//////////////			//	
	//////////////			//	
	//////////////			//	
	//////////////////////////
 
// PS: I don't really know JavaScript so this is probably a klugey solution.  But it works for me.
 
 
//Reading configuration or setting defaults if not present:
if(typeof markThisTabTitleConfig == 'undefined') {
	var  markThisTitle="Mark this shit";
}
else {
    var markThisTitle= markThisTabTitleConfig;
}
 
 
if(typeof myMarksTitleConfig == 'undefined') {
		var  myMarksTitle="My motherfuckin' gn0Marks";
}
else {
    var markThisTitle= markThisTabTitleConfig;
}
 
if(typeof WikimarkConfigWikimarksPage == 'undefined') {
    var wikimarkspage = "/mygn0Marks";
}
else {
    var wikimarkspage = "/"+WikimarkConfigWikimarksPage;
}
 
if(typeof WikimarkConfigKeepSection == 'undefined') {
    var wikimarksect = 0;
}
else {
    var wikimarksect = WikimarkConfigKeepSection;
}
 
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-";
}
 
if(typeof WikimarkConfigWikimarksUsername == 'undefined') {
    var wikimarkEncodedUserName = encodeURIComponent(wgUserName);
}
else {
    var wikimarkEncodedUserName = WikimarkConfigWikimarksUsername;
}
 
var wikimarklinkprefix = wgServer+wgScript;
 
$(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()', markThisTitle, menuPrefix+'addwikimark', 'Bookmark this page', '', addNextto);
    addPortletLink (viewMenulocation, wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage, myMarksTitle, menuPrefixV+'showwikimark', 'Open your gn0Marks', '', viewNextto);
}
 
function doAddWikiMark () {
    var wikimarkNewpage = wgPageName.replace(/_/g, " ");
    if(wikimarkNewpage.indexOf("File:")==0) {
        wikimarkNewpage = ":" + wikimarkNewpage;
    }
    else if(wikimarkNewpage.indexOf("Category:")==0) {
        wikimarkNewpage = ":" + wikimarkNewpage;
    }
    var wikimarkNewpageName = wikimarkNewpage;
  if(wikimarksect == 1) {
        var newpageURL = location.href;
        if(newpageURL.indexOf("#")) {
            anchor = newpageURL.split("#");
            newpageSect = anchor[1];
            var wikimarkNewpageLink = wikimarkNewpage;
            wikimarkNewpage = wikimarkNewpage + "#" + newpageSect;
            wikimarkNewpage = wikimarkNewpage.replace(/_/g, " ");
            wikimarkNewpageName = wikimarkNewpageLink + " (Section: " + newpageSect + ")";
        }
    }
 
    if(wikimarkNewpageName == wikimarkNewpage) {
    var wikimarkLinktext = wikimarkNewpage;
    }
 
    else {
        var wikimarkLinktext = wikimarkNewpage+"|"+wikimarkNewpageName;
    }
 
    var f;
    f=window.open(wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit")
    f.id="WikiMarksLoader";
    f.onload=function() {
	    var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list.";
        e=f.document.editform;
        e.wpTextbox1.value+=listtype+"["+"["+wikimarkLinktext+"]"+"]\n";
	    e.wpSummary.value=wikimark_cmt;
        e.wpSave.click();
//        f.close();        // This closes the gn0Marks window. You can comment it out if you prefer.
		jsMsg("You're the man now, dawg. '''"+wikimarkNewpageName+"''' has been added to your gn0Marks. Fuuuuck yyeaaahhh.");
    };
}