forked from thebaer/MMRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
42 lines (35 loc) · 1.15 KB
/
background.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
//
// Make Medium Readable Again
//
var makeReadable = function() {
// Un-position:fixed the top nav bar
var topNav = document.querySelector('.metabar.u-fixed');
if (topNav != null) {
topNav.classList.remove('u-fixed');
}
// Remove the footer
var getUpdatesBar = document.querySelector('.js-stickyFooter');
if (getUpdatesBar != null) {
getUpdatesBar.style.display = 'none';
}
};
var hideDickbar = function() {
document.querySelector('.js-postShareWidget').style.display = 'none';
document.querySelector('footer > .container:first-child').style.display = 'none';
};
var observer = new MutationObserver(function(mutations){
mutations.forEach(makeReadable);
});
var config = {attributes: true};
// Only run this on Medium sites.
// Ensure that by checking for <meta property="al:ios:app_name" content="Medium"> in the document <head />
var metaCheck = document.head.querySelector('meta[property="al:ios:app_name"]');
if (metaCheck != null && metaCheck.content == "Medium") {
makeReadable();
chrome.storage.sync.get(null, function(items) {
if (items.hideDickbar) {
hideDickbar();
}
});
observer.observe(document.querySelector('body'), config);
}