2 // @name RB-79 Userscript [ Change this ]
3 // @namespace RB-79 [ Change this ]
4 // @description Fancy features for RB-79 [ Change this ]
5 // @include http://127.0.0.1/* [ Change this ]
10 var img_re = /\.(png|gif|jpg|webp|jpeg|tif|tiff|bpg|svg)$/i;
11 var video_re = /\.(webm|mkv|mp4|mp3|ogg|m4a|flac|opus|mka)$/i;
14 * Turn off any sort of link for the userscript that's being advertised
16 document.querySelectorAll('.userscript-link').forEach(function(b) {
17 b.parentNode.removeChild(b);
21 * Turn all post numbers into clickable links, for quoting
23 document.querySelectorAll('span.post-number').forEach(function (s) {
24 s.onclick = function () {
25 document.querySelectorAll('textarea[name=comment]').forEach(function (t) {
26 t.value = t.value + '>>' + s.innerText.replace(/No. +/, '') + '\n';
29 s.innerHTML = '<a href="#" class="a-subtle">' + s.innerHTML + '</a>';
33 * Shift+Click to remove files
35 document.querySelectorAll('input[type=file]').forEach(function (i) {
36 i.title = 'Shift+Click to remove';
37 i.onclick = function (ev) {
47 * Expand images on click
49 document.querySelectorAll('a.filelink').forEach(function (s) {
50 if (img_re.test(s.href)) {
51 s.onclick = function (ev) {
56 this.childNodes[0].style.maxWidth = '95vw';
57 this.childNodes[0].style.maxHeight = '95vh';
58 this.expanded = this.childNodes[0].src;
59 this.childNodes[0].src = this.href;
61 this.childNodes[0].src = this.expanded;
66 } else if (video_re.test(s.href)) {
67 s.onclick = function (ev) {
73 aNode.expanded = 'yes';
74 var thumbNode = this.childNodes[0];
75 var parentNode = this.parentNode;
76 thumbNode.style.display = 'none';
77 var videoNode = document.createElement('video');
78 videoNode.src = this.href;
79 videoNode.controls = ' ';
81 videoNode.autoplay = ' ';
82 var closeNode = document.createElement('span');
83 var lBracket = document.createTextNode('[');
84 var closeLink = document.createElement('a');
85 var rBracket = document.createTextNode(']');
87 closeLink.innerText = 'Close';
88 closeLink.onclick = function (ev1) {
89 thumbNode.style.display = '';
91 parentNode.removeChild(videoNode);
92 parentNode.removeChild(closeNode);
95 closeNode.appendChild(lBracket);
96 closeNode.appendChild(closeLink);
97 closeNode.appendChild(rBracket);
98 parentNode.appendChild(closeNode);
99 parentNode.appendChild(videoNode);