Skip to content

Instantly share code, notes, and snippets.

@splosch
splosch / isSPContentPage.js
Last active January 9, 2019 14:56
Adds class "isSPContentPage" to body of webpages that are Sharepoint Content Pages - not so to Settings etc.
(function(){
var onDOMReady = function( fn ) {
if ( document.readyState !== 'loading' ) {
fn();
} else {
document.addEventListener( "DOMContentLoaded", fn );
}
},
markSPContentPages = function(){
var whitelist = [
// allow Object.values(myObject) for IE
// alternative in a npm controlled environment: https://www.npmjs.com/package/object.values
Object.values = Object.values ? Object.values : function(obj) {
var allowedTypes = ["[object String]", "[object Object]", "[object Array]", "[object Function]"];
var objType = Object.prototype.toString.call(obj);
if(obj === null || typeof obj === "undefined") {
throw new TypeError("Cannot convert undefined or null to object");
} else if(!~allowedTypes.indexOf(objType)) {
return [];

Keybase proof

I hereby claim:

  • I am splosch on github.
  • I am sploscho (https://keybase.io/sploscho) on keybase.
  • I have a public key ASADUU5Gv0WUK8OiMU2JIQ6AkkL0KWzvq72WBcjiy4-JLAo

To claim this, I am signing this object: