Skip to content

Instantly share code, notes, and snippets.

@Mido22
Created October 15, 2016 16:10
Show Gist options
  • Save Mido22/7e2fc285edc9a673e879bd38128ce66f to your computer and use it in GitHub Desktop.
Save Mido22/7e2fc285edc9a673e879bd38128ce66f to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name ballfoot.goToIFrame
// @match http://www.p2pfree.net/view-live-video/*
// @version 1.0.0
// @grant none
// @namespace https://gist.github.com/Mido22
// ==/UserScript==
(function(w, d){
'use strict'
w.addEventListener('load', () => {
addButton('go to src', onClick)
})
function onClick() {
let a = d.querySelector('.player600 iframe').src
if(a) d.location.href = a
}
function addButton(text, onclick, cssObj) {
cssObj = cssObj || {}
let dflt = {position: 'fixed', bottom: '7%', left:'13%', 'z-index': 3}
Object.keys(dflt).filter(k => !cssObj[k]).forEach(k => cssObj[k]=dflt[k])
let button = d.createElement('button'), btnStyle = button.style
d.body.appendChild(button)
button.innerHTML = text
button.onclick = onclick
btnStyle.position = 'absolute'
Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key])
return button
}
}(window, document))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment