Skip to content

Instantly share code, notes, and snippets.

@danikaze
Created December 18, 2018 09:03
Show Gist options
  • Save danikaze/888101ed937c43bc0619a30b7e6b9ad6 to your computer and use it in GitHub Desktop.
Save danikaze/888101ed937c43bc0619a30b7e6b9ad6 to your computer and use it in GitHub Desktop.
TamperMonkey script to show again profile photos in REPOC SuccessFactors
// ==UserScript==
// @name REPOC SuccessFactors Show photo again
// @namespace http://tampermonkey.net/
// @version 0.1.0
// @description Latest version of Success Factors REPOC hides the photo in the profile page. This script shows it again.
// @author danikaze
// @match https://performancemanager10.successfactors.com/xi/ui/pages/empfile/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function start() {
const img = createImage();
const wrapper = wrapContents(img);
wrapper.appendChild(img);
}
function wrapContents() {
const wrapper = document.createElement('div');
const contents = document.getElementById('__content0');
const parent = contents.parentElement;
contents.style = (contents.style ? contents.style + '; ' : '') + 'padding-left: 200px; min-height: 248px;';
wrapper.appendChild(contents);
parent.appendChild(wrapper);
return wrapper;
}
function createImage() {
const userId = window.selectedUserID;
const now = new Date().getTime();
const url = `/eduPhoto/view?companyId=Atago&photo_type=liveProfile&user_id=${userId}&invalidateCache=${now}`;
const img = document.createElement('img');
img.id = 'x-photo';
img.src = url;
img.style = 'position: absolute; top: 5px; left: 5px;';
img.height = 238
return img;
}
/**
* Poll a condition over time and resolve when the result true-ish
*/
function waitFor(condition, pollTime = 200) {
return new Promise((resolve) => {
function check() {
const result = condition();
if (result) {
resolve(result);
return;
}
setTimeout(check, pollTime);
}
check();
});
}
waitFor(() => document.getElementById('__content0'))
.then(() => waitFor(() => !document.getElementById('__layout2')))
.then(() => waitFor(() => document.getElementById('__xmlview0--localTime')))
.then(start);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment