Skip to content

Instantly share code, notes, and snippets.

@VencaV
Last active November 19, 2020 05:25
Show Gist options
  • Save VencaV/741147e472055d2ea42e687e4993c3f8 to your computer and use it in GitHub Desktop.
Save VencaV/741147e472055d2ea42e687e4993c3f8 to your computer and use it in GitHub Desktop.
var repository = document.querySelector('.phui-property-list-properties a[href*="/diffusion/"]');
if (repository) {
var color = '#136cb2';
var bgColor = '#fdf3da';
var borderColor = '#c9b8a8';
var bodyBg = '#f3f5f7';
var href = repository.getAttribute('href');
if (href.indexOf('CMSD') !== -1) {
color = '#ffffff';
bgColor = '#f7a12b';
borderColor = '#e68c0f';
bodyBg = '#ffe8c9';
} else if (href.indexOf('TPLS') !== -1) {
color = '#ffffff';
bgColor = '#a7c721';
borderColor = '#91b302';
bodyBg = '#f2ffbb';
} else if (href.indexOf('TPLC') !== -1) {
color = '#ffffff';
bgColor = '#dd2bf7';
borderColor = '#be1ad6';
bodyBg = '#f2c9ff';
} else if (href.indexOf('CRM') !== -1) {
color = '#ffffff';
bgColor = '#14b1ef';
borderColor = '#0092cc';
bodyBg = '#c4eeff';
}
var repository = repository.cloneNode(true);
var pattern = new RegExp(/r[a-zA-Z]*\s{1}/, 'g');
repository.innerText = repository.innerText.replace(pattern, '');
repository.setAttribute('style', 'position: fixed; right: 0; top: 0; z-index: 1000; min-width: 120px; padding: 1em; text-align: center; color: ' + color + '; border: 1px solid ' + borderColor +'; background-color: ' + bgColor + '; opacity: .98;');
document.body.appendChild(repository);
var style = document.createElement('style');
style.innerText = 'body { background: ' + bodyBg + '; }';
document.head.appendChild(style);
}
var handleCopy = (el) => {
var text = el.innerText;
el.addEventListener('click', () => {
var tmp = document.createElement('input');
tmp.setAttribute('value', text);
document.body.appendChild(tmp);
tmp.select();
document.execCommand('copy');
document.body.removeChild(tmp);
var copyConfirm = document.createElement('span');
copyConfirm.innerHTML = 'Copied to clipboard';
copyConfirm.setAttribute('id', 'copyConfirm');
copyConfirm.setAttribute('style', 'position: fixed; z-index: 1000; left: 1ex; bottom: 1ex; padding: 2em; color: #fff; background: rgba(0,0,0,.85); border: 1px solid #000; border-radius: 3px;')
el.parentNode.insertBefore(copyConfirm, el.nextSibling);
setTimeout(() => {
document.getElementById('copyConfirm').remove();
}, 3000);
});
el.innerText = text + ' ✂';
el.setAttribute('style', 'cursor: copy; width: auto; border-bottom: 1px dashed #a1a6b0;');
}
var patch = document.querySelector('.phui-property-list-value tt');
if (patch) {
handleCopy(patch);
}
var branch = document.querySelectorAll('.phui-property-list-value');
for (var i = 0; i < branch.length; i++) {
var regexp = new RegExp(/^T\d+/gm);
if (branch[i].innerHTML.match(regexp)) {
handleCopy(branch[i]);
}
}
var shoptetCommandsRevision = {
'subscriberPHIDs': {
label: '👨 Subscribers',
visible: true,
highlighted: false
},
'mfa': {
label: 'Sign With MFA',
visible: false,
highlighted: false
}
}
var shoptetCommandsTask = {
'subscriberPHIDs': {
label: '👨 Subscribers',
visible: true,
highlighted: false
},
'mfa': {
label: 'Sign With MFA',
visible: false,
highlighted: false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment