forked from lg188/volafile-scripts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
volafile-last-highlight.user.js
46 lines (37 loc) · 1.4 KB
/
volafile-last-highlight.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
// ==UserScript==
// @name Volafile last highlight
// @namespace volafile.last.highlight
// @description Takes you to the last highlight
// @include https://volafile.org/r/*
// @match https://volafile.org/r/*
// @version 2
// @grant none
// ==/UserScript==
function init() {
var chat = document.getElementById("chat_input");
function add_lazy_button(func) {
var button = document.createElement("SPAN");
//var button_text = document.createTextNode(text);
//button.appendChild(button_text);
button.addEventListener("click", func, true);
button.style = "user-select: none; -moz-user-select: none; margin-left: 5px;";
button.setAttribute("class", "icon-arrow-up clickable")
document.getElementById('chat_hbar').appendChild(button)
//document.getElementById('chat_name_container').insertBefore(button, document.getElementById('chat_name_container').parentNode.childNodes[0])
}
function go_to_last_highlight() {
var elems = document.getElementsByClassName("highlight");
console.log(elems);
elems[elems.length - 1].id = "lasthighlight"
window.location.hash = "lasthighlight"
elems[elems.length - 1].id = "";
}
add_lazy_button(go_to_last_highlight);
}
(function() {
var state = document.readyState;
if(state === 'interactive' || state === 'complete') {
init();
}
else setTimeout(arguments.callee, 100);
})();