Last active
June 11, 2020 12:59
-
-
Save silversillu/86d623bd96eeceb96a44ec6b72995259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
clearInterval(window.wait_for_test_elements); | |
window.wait_for_test_elements = setInterval(function(){ | |
if ( document.querySelector('[data-testid="sidebar"]') ) { | |
run_all(); | |
if ( document.location.pathname === "/" ) { | |
run_home(); | |
} else if ( document.location.pathname === "/games" ) { | |
//run_games(); | |
} | |
} | |
}, 50); | |
function run_all() { | |
if (!document.querySelector('#sidebar-new-element')){ | |
// Insert CSS | |
var css = | |
'div#sidebar-new-element {'+ | |
'border: 1px solid #8e9ea8;'+ | |
'text-align: center;'+ | |
'padding: 10px 10px 36px;'+ | |
'margin-top: 30px;'+ | |
'}'+ | |
'div#sidebar-new-element span {'+ | |
'display: inline-block;'+ | |
'background: #ff4f0f;'+ | |
'color: white;'+ | |
'padding: 7px 20px;'+ | |
'border-radius: 17px;'+ | |
'margin-top: 10px;'+ | |
'}' | |
; | |
var head = document.head || document.getElementsByTagName('head')[0]; | |
var style = document.createElement('style'); | |
style.type = 'text/css'; | |
if (style.styleSheet){ | |
// This is required for IE8 and below. | |
style.styleSheet.cssText = css; | |
} else { | |
style.appendChild(document.createTextNode(css)); | |
} | |
head.appendChild(style); | |
// Add an element to the sidebar | |
var sidebar = document.querySelector('[data-testid="sidebar"]'); | |
var sidebar_new_element = document.createElement('div'); | |
sidebar_new_element.setAttribute('id', 'sidebar-new-element'); | |
sidebar_new_element.innerHTML = '<h2>New item</h2><span>See details</span>'; | |
sidebar.appendChild(sidebar_new_element); | |
} | |
//console.log('works'); | |
} | |
function run_home() { | |
if ( document.querySelector('h3.main-banner-title') && document.querySelector('h3.main-banner-title').innerText != "Welcome to Bitcasino" ) { | |
document.querySelector('h3.main-banner-title').innerText = "Welcome to Bitcasino"; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment