-
Notifications
You must be signed in to change notification settings - Fork 0
/
atomic-cli-links.user.js
50 lines (42 loc) · 2.12 KB
/
atomic-cli-links.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// ==UserScript==
// @name Atomic CLI Links
// @namespace atomic-cli-links
// @version 1.2
// @description Adds links to CLI, VPMC and Revert tools on Atomic sites in Zendesk.
// @updateURL https://github.com/druesome/andrew-scripts/raw/main/atomic-cli-links.user.js
// @downloadURL https://github.com/druesome/andrew-scripts/raw/main/atomic-cli-links.user.js
// @author druesome
// @match https://*.apps.zdusercontent.com/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
var $ = window.jQuery;
// Add links to CLI if site is Atomic
function addcliLinks() {
$('.user__info_container .sites .site').each(function() {
var $site = $(this);
var $atomicSpan = $site.find('.atomic');
if ($atomicSpan.length > 0 && !$site.hasClass('cliadded')) {
$site.addClass('cliadded');
var siteURL = 'https://' + $site.find('.site-domain').first().text();
// Extract blog ID from Videos link
var videosLink = $site.find('.site-links a[title="VideoPress files"]');
var blogId = videosLink.attr('href').match(/blog=(\d+)/)[1];
// Add link to Revert tool using extracted blog ID
var revertLink = $('<a>').attr('href', 'https://mc.a8c.com/automated-transfer/revert.php?blog_id=' + blogId).attr('target', '_blank').text('Revert');
var revertListItem = $('<li>').append(revertLink);
$site.find('.site-links').append(revertListItem);
// Add link to VPMC
var vpmcLink = $('<a>').attr('href', 'https://mc.vaultpress.com/site/blog_id=' + blogId).attr('target', '_blank').text('VPMC');
var vpmcListItem = $('<li>').append(vpmcLink);
$site.find('.site-links').append(vpmcListItem);
// Add link to CLI
var cliLink = $('<a>').attr('href', siteURL + '/_cli').attr('target', '_blank').text('CLI');
var cliListItem = $('<li>').append(cliLink);
$site.find('.site-links').append(cliListItem);
}
});
}
// Loop until links are added
window.setInterval(function() {
addcliLinks();
}, 1000);