-
Notifications
You must be signed in to change notification settings - Fork 0
/
Random Post Button for ScratchStyle Theme.js
40 lines (36 loc) · 1.3 KB
/
Random Post Button for ScratchStyle Theme.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
// ==UserScript==
// @name Random Post Button for ScratchStyle Theme
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Brings you to a random post
// @author PhantomLuigi
// @match https://tbgforums.com/forums/index.php
// @match https://tbgforums.com/forums/
// @icon https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSAjpERaAppP79KwCPOUXpuQUAysjybXTWCvrUjvqE1sw&s
// @grant none
// ==/UserScript==
(function() {
'use strict';
const $ = document.querySelector.bind(document);
$('body').insertAdjacentHTML('beforeend', init_css() );
var min = 1
var max = 700000
var x = 0
setTimeout(() => {
//setTimeout needed to allow a few ms for the new Btn to be injected onto page
$('#random').addEventListener('click', () => {
x = Math.round (Math.random() * (max - min + 1)) + min;
window.open("https://tbgforums.com/forums/viewtopic.php?pid=" + x + "#p" + x);
});
},500);
})();
function init_css(){
return `
<button id="random">Random Post</button>
<style>
#random{position:absolute;top:74px;left:55%;height:25px;width:130px;}
#random{background:#0066B9;color:white;padding-top:0px;text-align:center;}
#random{z-index:0;}
</style>
`;
}