-
Notifications
You must be signed in to change notification settings - Fork 6
/
export.js
54 lines (43 loc) · 1.98 KB
/
export.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
51
52
53
54
// expandBlockList clicks the button which opens the blocklist
// Then it clicks the 'Show More' button until it is no longer visible
// The 'Show More' button still exists, and will loop through the block list if you continue to click it.
var expandBlockList = function (callback) {
$('document').ready( function () {
$("#blocked_blogs > .accordion_trigger_wrapper > .accordion_trigger").click();
var expandInterval = setInterval(function() {
if ($('#blocked_blogs > div.accordion_content.show > button').is(':visible')) {
$('#blocked_blogs > div.accordion_content.show > button').click();
} else {
clearInterval(expandInterval);
callback();
}
}, 500);
});
}
// getBlockList gathers all the blog names in a user's block list
// It returns the list as an array
var getBlockList = function () {
var i = 1;
var blocklist = [];
var blog = jQuery('#blocked_blogs > div.accordion_content.show > ul > li:nth-child(' + i++ + ') > div.blog-info > a.name');
while (blog !== undefined && blog[0] !== undefined) {
blocklist.push(blog[0].innerText);
var blog = jQuery('#blocked_blogs > div.accordion_content.show > ul > li:nth-child(' + i++ + ') > div.blog-info > a.name');
}
return blocklist;
}
expandBlockList(function() {
var blocklist = JSON.stringify(getBlockList());
blocklist = blocklist.replace('[','');
blocklist = blocklist.replace(']','');
while (blocklist.indexOf('\"') !== -1) {
blocklist = blocklist.replace('\"','');
}
// create a text area and insert it at the top of the sidebar
var right_column = document.getElementById('right_column');
var blockListTextArea = document.createElement('textarea');
blockListTextArea.setAttribute('id', 'blocklist');
blockListTextArea.style.background = 'white';
right_column.insertBefore(blockListTextArea, right_column.firstChild);
blockListTextArea.innerText = blocklist;
});