This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
no-releases-tamperscript.js
49 lines (43 loc) · 1.87 KB
/
no-releases-tamperscript.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
// ==UserScript==
// @name GitHub Block Releases
// @namespace https://github.com/saya-rbt
// @version 1.1
// @description Hides the releases on GitHub's homepage
// @author Saya @saya-rbt
// @match https://github.com/
// @icon https://www.google.com/s2/favicons?domain=github.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log("Running GitHub Block Releases...");
// Select the node that will be observed for mutations
const targetNode = document.getElementsByClassName('news')[0];
// Options for the observer (which mutations to observe)
const config = {childList: true, subtree: true, characterData: true};
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// Use traditional 'for loops' for IE 11
for(const mutation of mutationsList) {
if (mutation.type === 'childList') {
// Individual releases
var divs = document.getElementsByClassName("release");
for(var i = 0; i < divs.length; i++) {
divs[i].style.visibility = 'hidden';
divs[i].style.height = '0';
}
// When several releases are collapsed into a single div
// "wtf is the 'classes' attribute" idfk ask microsoft
divs = document.querySelectorAll("div[classes]");
for(i = 0; i < divs.length; i++) {
divs[i].style.visibility = 'hidden';
divs[i].style.height = '0';
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
})();