Last active
June 30, 2023 14:57
-
-
Save tiagoduarte/11992165b8cf08062316cc794ada1e0f to your computer and use it in GitHub Desktop.
Adds new buttons near the ribbon for typical SharePoint actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name SharePoint Dev Tools | |
// @namespace TiagoDuarte | |
// @description Adds new buttons near the ribbon for typical SharePoint actions | |
// @version 3.7 | |
// @grant none | |
// @match https://*.sharepoint.com/* | |
// ==/UserScript== | |
/* | |
release notes | |
v3.7 | |
- reworked SharePoint versioning checks (should be safe to run for non sharepoint sites) | |
- getAbsoluteUrl() method | |
- grants documentation, https://wiki.greasespot.net/Greasemonkey_Manual:API | |
//// @grant GM.getValue | |
//// @grant GM.setValue | |
//// @grant unsafeWindow | |
v3.6 | |
- fix error when safe link that ends up in https wrongly redirects to the http access requests page (query string check) | |
v3.5 | |
- add links to roles, groups and default groups | |
v3.4 | |
- go to navigation settings and navigation elements | |
v3.3 | |
- improved support for all versions (2010, 2013, online classic, online modern) | |
known issues: | |
- in office 365 modern sites, the panel button works randomly, possibly due to other scripts errors | |
v3.2 | |
- redirect https to http | |
v3.0 | |
- switched to a sliding panel | |
v2.0 | |
- sharepoint server version button | |
v1.9 | |
- recycle item (useful for access requests) | |
v1.8 | |
- added mirror library button | |
*/ | |
function addJQuery(callback) { | |
var script = document.createElement("script"); | |
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"); | |
script.addEventListener('load', function() { | |
var script = document.createElement("script"); | |
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();"; | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); | |
} | |
function main() { | |
function getAbsoluteUrl() | |
{ | |
if(typeof _spPageContextInfo != "undefined") | |
{ | |
return _spPageContextInfo.webAbsoluteUrl; | |
} | |
else | |
{ | |
var returnUrl = window.location.href; | |
if(returnUrl.indexOf("/teams/") === -1 && returnUrl.indexOf("/sites/") === -1) | |
{ | |
returnUrl = new URL(returnUrl); | |
returnUrl = "https://" + returnUrl.hostname; | |
} | |
if(returnUrl.indexOf("/teams/") !== -1) | |
{ | |
returnUrl = new URL(returnUrl); | |
var relPathNameTeams = returnUrl.pathname.replace("/teams/", ""); | |
if(relPathNameTeams.indexOf("/") !== -1) | |
relPathNameTeams = relPathNameTeams.replace(/\/.*/, ""); | |
returnUrl = "https://" + returnUrl.hostname + "/teams/" + relPathNameTeams; | |
} | |
if(returnUrl.indexOf("/sites/") !== -1) | |
{ | |
returnUrl = new URL(returnUrl); | |
var relPathNameSites = returnUrl.pathname.replace("/sites/", ""); | |
if(relPathNameSites.indexOf("/") !== -1) | |
relPathNameSites = relPathNameSites.replace(/\/.*/, ""); | |
returnUrl = "https://" + returnUrl.hostname + "/sites/" + relPathNameSites; | |
} | |
return returnUrl; | |
} | |
} | |
//adds the open/close button, adds also the invididual buttons | |
//each image is taken from the sprite. exceptions can be used | |
//button wrapped already added to body tag | |
function AddDevToolsButton(id, btn_title, img_x, img_y, callback) | |
{ | |
if(id == "openClosePanel" && document.getElementById("openClosePanel") !== null) | |
{ | |
console.log("[SPDT] Panel already added."); | |
return; | |
} | |
var rootElement = '#spdevtools-panel'; | |
//*** BUTTONS *** | |
//each button must associated to a root/parent element (the element that will store this button's html as a child) | |
//IN DIALOGS, SHOW A LINK TO THE URL IN THE IFRAME | |
if (id == 'getIframeLink' && window.location.href.indexOf('IsDlg') > -1) | |
{ | |
rootElement = '.ms-cui-topBar2'; | |
} | |
//SHAREPOINT 2010 - OPEN/CLOSE BUTTONo | |
if(id == "openClosePanel" && typeof _spPageContextInfo != "undefined" && _spPageContextInfo.webUIVersion === 4) | |
{ | |
rootElement = '#RibbonContainer-TabRowRight'; | |
console.log("[SPDT] SP2010 detected"); | |
} | |
//SHAREPOINT 2016/2019 - OPEN/CLOSE BUTTON | |
if(id == "openClosePanel" && document.getElementById("O365_TopMenu") !== null && window.location.href.indexOf(".sharepoint.com") === -1) | |
{ | |
rootElement = '#O365_TopMenu > div > span'; | |
console.log("[SPDT] SP2016/2019 detected"); | |
} | |
//SHAREPOINT 2013 - OPEN/CLOSE BUTTON | |
if(id == "openClosePanel" && document.getElementById("O365_TopMenu") === null && typeof _spPageContextInfo != "undefined" && _spPageContextInfo.webUIVersion === 15 && window.location.href.indexOf(".sharepoint.com") === -1) | |
{ | |
rootElement = '#siteactiontd'; | |
console.log("[SPDT] SP2013 detected"); | |
} | |
//SHAREPOINT ONLINE - OPEN/CLOSE BUTTON (CONTEXT) | |
if(id == "openClosePanel" && document.getElementById("O365_TopMenu") === null && window.location.href.indexOf(".sharepoint.com") !== -1 && typeof _spPageContextInfo != "undefined") | |
{ | |
rootElement = '#HeaderButtonRegion'; | |
console.log("[SPDT] SPO detected (context available)"); | |
/* | |
if(typeof unsafeWindow != "undefined") | |
{ | |
var _spPageContextInfoTemp = { webServerRelativeUrl:"ola", webAbsoluteUrl:"xau"}; | |
unsafeWindow._spPageContextInfo = _spPageContextInfoTemp; | |
//GM.setValue('_spPageContextInfo', _spPageContextInfoTemp); | |
console.log("[SPDT] _spPageContextInfo instantiated"); | |
} | |
*/ | |
} | |
//SHAREPOINT ONLINE - OPEN/CLOSE BUTTON (NO CONTEXT) | |
if(id == "openClosePanel" && document.getElementById("O365_TopMenu") === null && window.location.href.indexOf(".sharepoint.com") !== -1 && typeof _spPageContextInfo == "undefined") | |
{ | |
rootElement = '#HeaderButtonRegion'; | |
console.log("[SPDT] SPO detected (context not available)"); | |
} | |
//sprite path | |
var imgPath2010 = "/_layouts/1033/images/formatmap16x16.png"; | |
var imgPath2013 = "/_layouts/15/1033/images/formatmap16x16.png"; | |
var imgPath = imgPath2010; | |
//override recycle button icons | |
if(id == "openRecycleBin" || id === "openRecycleBinAdmin") | |
{ | |
imgPath = "/_layouts/images/recycbin.gif"; | |
} | |
//button html | |
var toAdd = ""; | |
toAdd += '<span style="background:none;cursor:pointer;text-align:left;" class="s4-breadcrumb-anchor" id="' + id + '"><span class="ms-cui-img-16by16 ms-cui-img-cont-float" style="margin-left:auto;margin-right:auto;position:relative;width:16px;height:16px;display:inline-block;overflow:hidden;" unselectable="on"><img alt="' + btn_title + '" title="' + btn_title + '" style="position:absolute;top: ' + img_y + '; left: ' + img_x + ';" src="' + imgPath + '" alt="" unselectable="on" /></span> ' + btn_title + '</span>'; | |
toAdd += "<br/>"; | |
//console.log("[SPDV] Adding button: " + rootElement); | |
//commit add | |
jQ(rootElement).append(toAdd); | |
eval(callback) (); | |
//MAKE SURE RIBBONS ARE ALWAYS VISIBLE IF HIDDEN | |
if(jQ("#suiteBar").css("display") === "none") | |
{ | |
jQ("#suiteBar").css("display", "block"); | |
} | |
if(jQ("#ms-designer-ribbon").css("display") === "none") | |
{ | |
jQ("#ms-designer-ribbon").css("display", "block"); | |
} | |
} | |
function CmdViewAllSiteContent() | |
{ | |
jQ('#siteContentLink').click(function () { | |
window.location.href = getAbsoluteUrl().replace(/\/$/, "") + "/_layouts/15/viewlsts.aspx"; | |
}); | |
} | |
function CmdExplorerView() | |
{ | |
jQ('#customOpenInExplorer').click(function () { | |
var urlToOpen = 'file://' + (location.hostname + (location.port ? ':' + location.port : '') + location.pathname.substring(0, location.pathname.lastIndexOf('/')).replace('/Forms', '')); | |
window.prompt('Here is the path for file explorer', urlToOpen); | |
}); | |
} | |
function CmdHomeView() | |
{ | |
jQ('#customOpenInHome').click(function () { | |
window.location.href = getAbsoluteUrl(); | |
}); | |
} | |
function openClosePanel() | |
{ | |
jQ('#openClosePanel').click(function () { | |
jQ("#spdevtools-panel-wrapper").toggle(); | |
}); | |
} | |
function CmdViewCount() | |
{ | |
jQ('#getViewCount').click(function () | |
{ | |
if(ctx.TotalListItems == null) | |
alert("View Count is null: Try mouseover on the view."); | |
else | |
alert("View Count (this page only): " + ctx.TotalListItems); | |
}); | |
} | |
function CmdExpandScroll() | |
{ | |
jQ('#makeFullScreen').click(function () | |
{ | |
jQ("#s4-workspace").css("height", "100%").css("overflow", "visible"); | |
alert("scroll expanded!"); | |
} | |
); | |
} | |
function CmdItemCount() | |
{ | |
jQ('#getListCount').click(function () { | |
var itemcount = 0; | |
var context = SP.ClientContext.get_current(); | |
var web = context.get_web(); | |
var currentList = web.get_lists().getByTitle(ctx.ListTitle); | |
context.load(currentList); | |
context.executeQueryAsync( | |
Function.createDelegate(this, function(sender, args){ | |
alert('List Item Count: ' + currentList.get_itemCount()); | |
}), | |
Function.createDelegate(this, function(sender, args){ | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
}) | |
); | |
}); | |
} | |
function CmdWebTemplateID() | |
{ | |
jQ('#getWebTemplateID').click(function () { | |
window.prompt('Here is this site Template ID', g_wsaSiteTemplateId); | |
}); | |
} | |
function CmdWebID() | |
{ | |
jQ('#getWebID').click(function () { | |
var context = new SP.ClientContext.get_current(); | |
web = context.get_web(); | |
context.load(web); | |
context.executeQueryAsync( | |
Function.createDelegate(this, function(sender, args){ | |
window.prompt('Here is this site Template ID', web.get_id()); | |
}), | |
Function.createDelegate(this, function(sender, args){ | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
}) | |
); | |
}); | |
} | |
function CmdListTemplateID() | |
{ | |
jQ('#getListTemplateID').click(function () { | |
window.prompt('Here is this list Template ID', g_wsaListTemplateId); | |
}); | |
} | |
function CmdSaveTemplate() | |
{ | |
jQ('#saveSiteAsTemplate').click(function () { | |
var currentUrl = (window.location.href.substring(0, window.location.href.lastIndexOf('/'))); | |
currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/')); | |
window.location.href = currentUrl + "/_layouts/savetmpl.aspx"; | |
}); | |
} | |
function areYouSure(message) | |
{ | |
return confirm('Are you sure you want to: ' + message); | |
} | |
function GoToListSettings() | |
{ | |
jQ('#listSettingsLink').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/listedit.aspx?List=" + _spPageContextInfo.pageListId; | |
}); | |
} | |
function GoToSiteSettings() | |
{ | |
jQ('#siteSettingsLink').click(function () { | |
var settingsUrl = getAbsoluteUrl() + "/_layouts/15/settings.aspx"; | |
//console.log(settingsUrl); | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/settings.aspx"; | |
}); | |
} | |
function GoToSiteSettingsNavElem() | |
{ | |
jQ('#siteSettingsLinkNavElem').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/navoptions.aspx"; | |
}); | |
} | |
function GoToSiteSettingsNavSet() | |
{ | |
jQ('#siteSettingsLinkNavSet').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/AreaNavigationSettings.aspx"; | |
}); | |
} | |
//discontinued | |
function GoToListSync() | |
{ | |
jQ('#listSyncLink').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/REDACTED/ExtShareList.aspx?List=" + _spPageContextInfo.pageListId; | |
}); | |
} | |
function RecycleList() { | |
jQ('#recycleList').click(function () { | |
if(!areYouSure("Recycle the current list?")) | |
{ | |
return; | |
} | |
var context = SP.ClientContext.get_current(); | |
var web = context.get_web(); | |
var currentList = web.get_lists().getByTitle(ctx.ListTitle); | |
context.load(currentList); | |
currentList.recycle(); | |
context.executeQueryAsync( | |
Function.createDelegate(this, function(sender, args){ | |
alert("List recycled!"); | |
window.location.href = getAbsoluteUrl(); | |
}), | |
Function.createDelegate(this, function(sender, args){ | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
}) | |
); | |
}); | |
} | |
function RecycleItem() { | |
jQ('#recycleItem').click(function () { | |
if(!areYouSure("Recycle the current item?")) | |
{ | |
return; | |
} | |
var context = SP.ClientContext.get_current(); | |
var web = context.get_web(); | |
var currentList = web.get_lists().getByTitle(ctx.ListTitle); | |
var items = SP.ListOperation.Selection.getSelectedItems(ctx); | |
if(items.length !== 1) | |
{ | |
alert("must only select one item!"); | |
} | |
else | |
{ | |
var itemToDelete = currentList.getItemById(items[0].id); | |
itemToDelete.recycle(); | |
context.executeQueryAsync( | |
Function.createDelegate(this, function(sender, args){ | |
alert("Item recycled!"); | |
window.location.href = window.location.href; | |
}), | |
Function.createDelegate(this, function(sender, args){ | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
}) | |
); | |
} | |
}); | |
} | |
function CmdCheckedOutDocs() | |
{ | |
jQ('#seeCheckOutDocs').click(function () { | |
window.location.href = window.location.href + '?SortField=CheckoutUser&SortDir=Desc'; | |
}); | |
} | |
function CmdRefreshPage() | |
{ | |
jQ('#refreshThisPage').click(function () { | |
window.location.href = window.location.href.replace('#', ''); | |
}); | |
} | |
function CmdOpenSitePermissions() | |
{ | |
jQ('#openSitePermissions').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/user.aspx"; | |
}); | |
} | |
function CmdOpenCheckVersion() | |
{ | |
jQ('#checkVersion').click(function () { | |
var context = SP.ClientContext.get_current(); | |
context.executeQueryAsync( | |
Function.createDelegate(this, function(sender, args){ | |
//var serverVersion = context.get_serverVersion(); | |
alert("ServerVersion: " + context.get_serverVersion() + " ServerSchemaVersion: " + context.get_serverSchemaVersion()); | |
}), | |
Function.createDelegate(this, function(sender, args){ | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
}) | |
); | |
}); | |
} | |
function CmdOpenCheckRoles() | |
{ | |
jQ('#checkRoles').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/role.aspx"; | |
}); | |
} | |
function CmdOpenCheckSiteGroups() | |
{ | |
jQ('#checkSiteGroups').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/groups.aspx"; | |
}); | |
} | |
function CmdOpenCheckDefaultGroups() | |
{ | |
jQ('#checkDefaultGroups').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/permsetup.aspx"; | |
}); | |
} | |
function CmdOpenRecycleBin() | |
{ | |
jQ('#openRecycleBin').click(function () { | |
window.location.href = getAbsoluteUrl() + "/_layouts/15/AdminRecycleBin.aspx"; | |
}); | |
} | |
function CmdOpenRecycleBinAdmin() | |
{ | |
jQ('#openRecycleBinAdmin').click(function () { | |
window.location.href = _spPageContextInfo.siteAbsoluteUrl + "/_layouts/15/AdminRecycleBin.aspx?View=2"; | |
}); | |
} | |
function CmdCreateFolder() | |
{ | |
jQ('#createFolder').click(function () { | |
window.location.href = ctx.listUrlDir + "/Forms/Upload.aspx?RootFolder=" + encodeURIComponent(ctx.listUrlDir) + "&Type=1"; | |
}); | |
} | |
function CmdSignInAsAnotherUser() | |
{ | |
jQ('#signInAsAnotherUser').click(function () { | |
var signInUrl = ""; | |
if(_spPageContextInfo.webUIVersion === 4) | |
{ | |
signInUrl = "/_layouts/closeConnection.aspx?loginasanotheruser=true";//2010 | |
} | |
else | |
{ | |
signInUrl = "/_layouts/15/closeConnection.aspx?loginasanotheruser=true";//2013 | |
} | |
var sourceUrl = window.location.href; | |
var encodedSourceUrl = encodeURIComponent(sourceUrl).replace(/\./g, '%2E'); | |
var currentWebUrl = getAbsoluteUrl(); | |
if(currentWebUrl === "/") | |
{ | |
currentWebUrl = ""; | |
} | |
var navigateUrl = currentWebUrl + signInUrl + "&Source=" + encodedSourceUrl; | |
window.location.href = navigateUrl; | |
}); | |
} | |
function CmdListSettingsLink() | |
{ | |
jQ('#replaceListLink').click(function () { | |
if(window.location.href.toLocaleLowerCase().indexOf("/_layouts/listedit.aspx?list=") > 0 || window.location.href.toLocaleLowerCase().indexOf("/_layouts/15/listedit.aspx?list=") > 0) | |
{ | |
$("#idItemHoverTable th:contains('Web Address:')").next().html("<a href='" + $("#idItemHoverTable th:contains('Web Address:')").next().html() + "'>" + "click here to go back to the list</a>"); | |
} | |
}); | |
} | |
function CmdIframeLink() | |
{ | |
jQ('#getIframeLink').click(function () { | |
var iframeUrl = "not found"; | |
if(window.location.href.indexOf('IsDlg') == -1) | |
{ | |
iframeUrl = window.location.href.replace('#', ''); | |
} | |
else | |
{ | |
var parentWindow = window.parent.document; | |
var iframes = jQ('iframe', parentWindow); | |
for (var i = 0; i < iframes.length; i++) | |
{ | |
if ((iframes[i] !== null) && (iframes[i].src !== null)) | |
{ | |
if (iframes[i].src.indexOf('http://') > - 1) | |
{ | |
iframeUrl = iframes[i].src.replace("&IsDlg=1", ""); | |
} | |
} | |
} | |
} | |
window.prompt('Here is the URL for this page/frame', iframeUrl); | |
}); | |
} | |
jQ(document).ready(function () { | |
var curUrl = new URL(window.location.href); | |
console.log("[SPDT] SP Dev Tools active on " + curUrl.hostname); | |
//add button wrapped before closing body tag | |
var panelHtml = '<div id="spdevtools-panel-wrapper" style="overflow:auto; position: absolute;top: 83px;right: 0;background: lightgray;width: 250px;height: 100%;z-index: 1000000;padding: 20px; display:none;"><div id="spdevtools-panel" style="height:calc(100vh - 150px);overflow-y:auto;"><p>BUTTONS</p></div></div>'; | |
jQ("body").append(panelHtml); | |
//CONTEXT EXISTS: DEFINITELY A SHAREPOINT SITE | |
if(typeof _spPageContextInfo !== 'undefined') | |
{ | |
AddDevToolsButton('openClosePanel', '', '-128px','-32px', openClosePanel); | |
} | |
else | |
{ | |
//CONTEXT DOES NOT EXIST - try waiting if SPO | |
//console.log("[SPDT] _spPageContextInfo not defined!"); | |
if(window.location.href.indexOf(".sharepoint.com") !== -1) | |
{ | |
var timesRun = 0; | |
var checkExist = setInterval(function() { | |
//make sure the timer does not run forever | |
timesRun += 1; | |
if(timesRun === 100){ | |
clearInterval(checkExist); | |
console.log("[SPDT] SP not found"); | |
} | |
else | |
{ | |
if (document.getElementById("HeaderButtonRegion") !== null) { | |
//console.log("[SPDT] Button added at later time"); | |
AddDevToolsButton('openClosePanel', '', '-128px','-32px', openClosePanel); | |
clearInterval(checkExist); | |
} | |
else | |
{ | |
console.log("[SPDT] Waiting for DOM"); | |
} | |
} | |
}, 100); | |
} | |
else | |
{ | |
console.log("[SPDT] SP not found"); | |
return; | |
} | |
} | |
//using 2010 sprint - not pickable in spritecow, but supported in 2010+2013+office 365 | |
AddDevToolsButton('siteSettingsLink', 'Open site settings', '-152px','0', GoToSiteSettings);//-169px -56px | |
AddDevToolsButton('siteSettingsLinkNavSet', 'Open Navigation Settings', '-152px','0', GoToSiteSettingsNavSet);//-169px -56px | |
AddDevToolsButton('siteSettingsLinkNavElem', 'Open Navigation Elements', '-152px','0', GoToSiteSettingsNavElem);//-169px -56px | |
AddDevToolsButton('customOpenInHome', 'Open home page', '-176px','-112px', CmdHomeView); | |
AddDevToolsButton('siteContentLink', 'Open site content', '-176px','-112px', CmdViewAllSiteContent); | |
AddDevToolsButton('customOpenInExplorer', 'Open with Explorer', '-176px','-112px', CmdExplorerView); | |
AddDevToolsButton('makeFullScreen', 'fix overflow (screen shots)', '-176px','-112px', CmdExpandScroll); | |
AddDevToolsButton('getListCount', 'Get current list ItemCount', '-223px','-240px', CmdItemCount); | |
AddDevToolsButton('getViewCount', 'Get current view ItemCount', '-208px','-113px', CmdViewCount); | |
AddDevToolsButton('recycleList', 'Recycle this list', '-222px', '-111px', RecycleList); | |
AddDevToolsButton('recycleItem', 'Recycle this item', '-222px', '-111px', RecycleItem); | |
AddDevToolsButton('getWebID', 'Get Web ID', '-80px','-48px', CmdWebID); | |
AddDevToolsButton('getWebTemplateID', 'Get Web Template ID', '-80px','-48px', CmdWebTemplateID); | |
AddDevToolsButton('getListTemplateID', 'Get List Template ID', '-80px','-48px', CmdListTemplateID); | |
AddDevToolsButton('refreshThisPage', 'Refresh Page (no resubmit)', '-192px','-240px', CmdRefreshPage); | |
AddDevToolsButton('seeCheckOutDocs', 'See Checked Out Documents', '0px','-224px', CmdCheckedOutDocs); | |
AddDevToolsButton('getIframeLink', 'Get a link for this page', '-224px','-160px', CmdIframeLink); | |
AddDevToolsButton('listSettingsLink', 'Get to list settings', '-152px','0', GoToListSettings);//-169px -56px | |
AddDevToolsButton('listSyncLink', 'Enable list mirroring/sync', '-152px','0', GoToListSync);//-169px -56px | |
//AddDevToolsButton('replaceListLink', 'Enable the list settings link', '-224px','-160px', CmdListSettingsLink); | |
AddDevToolsButton('signInAsAnotherUser', 'Sign in as a different user', '-112px','-160px', CmdSignInAsAnotherUser); | |
AddDevToolsButton('createFolder', 'Create Folder', '-248px','-16px', CmdCreateFolder); | |
AddDevToolsButton('openSitePermissions', 'Open site permissions', '-200px','-16px', CmdOpenSitePermissions); | |
AddDevToolsButton('openRecycleBin', 'Open end user recycle bin', '0px','0px', CmdOpenRecycleBin); | |
AddDevToolsButton('openRecycleBinAdmin', 'Open second stage recycle bin', '0px','0px', CmdOpenRecycleBinAdmin); | |
AddDevToolsButton('checkVersion', 'Check Server Version', '-128px','-32px', CmdOpenCheckVersion); | |
AddDevToolsButton('checkRoles', 'Display Permission Levels (Roles)', '-128px','-32px', CmdOpenCheckRoles); | |
AddDevToolsButton('checkSiteGroups', 'Display Site Groups', '-128px','-32px', CmdOpenCheckSiteGroups); | |
AddDevToolsButton('checkDefaultGroups', 'Display Default Groups', '-128px','-32px', CmdOpenCheckDefaultGroups); | |
//AddDevToolsButton('saveSiteAsTemplate', 'Save this site as a template', '0px','-112px', CmdSaveTemplate); | |
//using 2013 sprint - pickable in spritecow, but image is different in office 365 | |
/* | |
AddDevToolsButton('customOpenInExplorer', 'Open with Explorer', '-187px','-55px', CmdExplorerView); | |
AddDevToolsButton('getListCount', 'Get current list ItemCount', '-289px','-91px', CmdItemCount); | |
AddDevToolsButton('getViewCount', 'Get current view ItemCount', '-241px','-37px', CmdViewCount); | |
AddDevToolsButton('recycleList', 'Recycle this list', '-271px', '-272px', RecycleList); | |
AddDevToolsButton('getWebID', 'Get Web ID', '-55px','-99px', CmdWebID); | |
AddDevToolsButton('getWebTemplateID', 'Get Web Template ID', '-55px','-99px', CmdWebTemplateID); | |
AddDevToolsButton('getListTemplateID', 'Get List Template ID', '-55px','-99px', CmdListTemplateID); | |
AddDevToolsButton('refreshThisPage', 'Refresh Page (no resubmit)', '-297px','-56px', CmdRefreshPage); | |
AddDevToolsButton('seeCheckOutDocs', 'See Checked Out Documents', '-201px','-272px', CmdCheckedOutDocs); | |
AddDevToolsButton('getIframeLink', 'Get a link for this page', '-37px','-287px', CmdIframeLink); | |
AddDevToolsButton('listSettingsLink', 'Get to list settings', '-169px','-56px', GoToListSettings);//-169px -56px | |
//AddDevToolsButton('replaceListLink', 'Enable the list settings link', '-224px','-160px', CmdListSettingsLink); | |
AddDevToolsButton('signInAsAnotherUser', 'Sign in as a different user', '-163px','-235px', CmdSignInAsAnotherUser); | |
AddDevToolsButton('createFolder', 'Create Folder', '-181px','-164px', CmdCreateFolder); | |
AddDevToolsButton('openSitePermissions', 'Open site permissions', '-73px','-145px', CmdOpenSitePermissions); | |
AddDevToolsButton('openRecycleBin', 'Open end user recycle bin', '0px','0px', CmdOpenRecycleBin); | |
AddDevToolsButton('openRecycleBinAdmin', 'Open second stage recycle bin', '0px','0px', CmdOpenRecycleBinAdmin); | |
AddDevToolsButton('checkVersion', 'Check Server Version', '-73px','-145px', CmdOpenCheckVersion); | |
//AddDevToolsButton('saveSiteAsTemplate', 'Save this site as a template', '0px','-112px', CmdSaveTemplate); | |
*/ | |
//auto replace list settings url with "go back" clickable hyperlink | |
if(window.location.href.toLocaleLowerCase().indexOf("/_layouts/listedit.aspx?list=") > 0 || window.location.href.toLocaleLowerCase().indexOf("/_layouts/15/listedit.aspx?list=") > 0) | |
{ | |
jQ("#idItemHoverTable th:contains('Web Address:')").next().html("<a href='" + jQ("#idItemHoverTable th:contains('Web Address:')").next().html() + "'>" + "click here to go back to the list</a>"); | |
} | |
//autosubmit | |
if(window.location.href.indexOf("&AutoSubmit=1") > 0) | |
{ | |
console.log("auto submitting form..."); | |
jQ("form input[type='submit'][value='OK']").trigger("click") | |
} | |
//REDACTED http redirect | |
//attempt to auto redirect content organizer page | |
/* | |
if(window.location.href.indexOf("/_layouts/15/routermessage.aspx") > 0) | |
{ | |
//$("a").remove(); | |
//$("#DeltaPlaceHolderMain > span").html("The document was submitted successfully and saved to its final location."); | |
} | |
*/ | |
/* | |
//auto revert page template | |
if($(".ms-status-body:contains('The current page has been customized from its template. ')").length === 1) | |
{ | |
console.log("reverting template"); | |
javascript:__doPostBack('__Page','RevertContentStream'); | |
} | |
*/ | |
}); | |
} | |
addJQuery(main); | |
//setTimeout(function(){ addJQuery(main); }, 3000); |
v0.8 updates:
- add current list itemcount
v0.9 updates:
- add support for v14/v15 sprite
- add recycle current list button
- "fix" icon posx/posy order in function call
v1.0 updates:
- added "see checked out files" button
v1.1 updates:
- added "open site permissions" button
v1.3 updates:
-
add new folder icon
-
icon updates (find alternatives for duplicate icons)
v3.7 updates:
- improved validations
- SharePoint version check/display
- support for SP2010/2013/2016/2019/Online
- for SPOnline, support waiting for the root element before adding the button (for slower loads)
- can now work without _spPageContextInfo if one is not found (uses alternative method to get the current web url)
- JQuery now loaded during runtime instead of using 'require' which seems to do a great job in supporting both sites that already have jquery as well as sites that do not have jquery
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
V0.7 updates: