-
Notifications
You must be signed in to change notification settings - Fork 1
/
DiscussionBoardTweak.js
60 lines (56 loc) · 2.19 KB
/
DiscussionBoardTweak.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
55
56
57
58
59
60
let defaults={
gcMaxTweak:true,
gcFilterTweak:true,
gcScrollBarTweak:true,
dbAddDownloadAll:true,
dlAssignmentsShowAll:true,
userShowAll:true,
needsGradingShowAll:true,
poolQuestionsShowAll:true,
gradeQuestionsShowAll:true,
fixPaste:true,
addDisableUsers:true,
hideRemoveUsers:true,
gcEnableDisableUsers:true,
gcEnableScrollOnTable:true,
gradingAddStudentIDs:true,
gradeDetailsShowJumpTo:true,
gcHoverAddedDate:true,
gcCopyUsernames:true,
gcDeleteUsers:true,
gcHideBulkUsers:true,
copyItemSearchCourses:true,
addCourseSwitch:true,
gcCopyUsernamesDel:'; ',
gcHScrollSensitivity:100,
gcVScrollSensitivity:100
};
browser.storage.sync.get(defaults).then(function(options){
if(options.dbAddDownloadAll){
var script = document.createElement("script");
script.innerHTML = `
jQuery(document).ready(function downloadPostZip(){
var jsZipScript = document.createElement("script");
jsZipScript.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js";
jsZipScript.type="text/javascript";
jsZipScript.onload = function() {
try{
var forumName = jQuery(".path a[title^='Forum:'").attr('title').substring(7);
}
catch (e){
var forumName = "DiscussionBoard";
}
var dbExZip = new JSZip();
jQuery(".dbThread").each(function(i,v){
dbExZip.file(jQuery(".profileCardAvatarThumb",v).text().trim()+i+".txt",jQuery(".dbThreadBody",v).text().trim())
});
dbExZip.generateAsync({type:"base64"}).then(function (base64) {
jQuery("#actionbar .u_floatThis-left").append('<li class="mainButton" style="position: relative;"><a id="JSZipDownload" download="'+forumName+'" href="data:application/zip;base64,'+base64+'">Download Zip</a></li>');
});
}
document.head.appendChild(jsZipScript);
});
`;
document.body.appendChild(script);
}
});