Skip to content

Instantly share code, notes, and snippets.

@intoverflow
Created February 7, 2011 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intoverflow/814068 to your computer and use it in GitHub Desktop.
Save intoverflow/814068 to your computer and use it in GitHub Desktop.
GSTL Greaser
// ==UserScript==
// @name VLCGOMGreaser
// @namespace brok3r.org
// @description Get VLC link from GOMTV SQLive
// @include http://www.gomtv.net/*
// ==/UserScript==
//
/* Discussion. 10 Jan 2010
At present time, GomTV has 3 buttons that appear on the *live* site. Each
triggers the class method Live.play(), passing in a parameter that dictates
stream quality.
Live.play() does some Ajax and creates a URL, stored in the local variable
"goxUrl". If you go to this URL, you get an HTML document which contains
a conspicuous tag, which itself has an attribute that is *another* URL.
This new URL has, as one of its key/value pairs, a pairing with key
"LiveAddr". If you decode the associated value (it's in URL-style
encoding), you get a URL that you can give to VLC.
*/
// javascript:live.addGox=function(title,url){ alert(url); };void(0);
// html body div#wrapper div#league_mainBody div#chbody_container div#ch_content_container div#livepage_view_1 div#box_viewlive_outter div#sq_test div.box_viewlive_inner a#btn_ch_view_on
// var playBtn = findXPathNode("//*[@id=\"sq_test\"]/div/*[@id=\"btn_ch_view_on\"]");
var playBtn = findXPathNode("//*[@id=\"btn_test_hq\"]");
GM_log(playBtn.href);
playBtn.href = "javascript:live.addGox=function(title,url){ brok3r_processGoxUrl(url); };live.play('SQ');void(0);";
function contentEval(source) {
// Check for function input.
if ('function' == typeof source) {
// Execute this function with no arguments, by adding parentheses.
// One set around the function, required for valid syntax, and a
// second empty set calls the surrounded function.
source = '(' + source + ')();'
}
// Create a script node holding this source code.
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = source;
// Insert the script node into the page, so it will run, and immediately
// remove it to clean up.
document.body.appendChild(script);
document.body.removeChild(script);
}
contentEval(function() {
brok3r_processGoxUrl = function(url) {
var client = new XMLHttpRequest();
client.open("GET", url, true);
client.onreadystatechange = function () {
if(client.readyState==4) {
var contents = client.responseText;
var start = contents.indexOf("LiveAddr=") + "LiveAddr=".length;
var end = contents.indexOf(";\"/");
var url = unescape(contents.substring(start,end));
// var insertion = findXPathNode("//*[@id=\"chmenu_title_container\"]");
var insertion = findXPathNode("//*[@id=\"mainTitle\"]");
insertion.innerHTML += "<a href=\">"+url+"</a>";
}
}
client.send(null);
};
findXPathNode = function(xpath, start, doc) {
var result = (doc == null ? document : doc).evaluate( xpath
, (start == null ? document : start)
, null
, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE
, null);
return (result.snapshotLength > 0 ? result.snapshotItem(0) : null);
};
})
function findXPathNode(xpath, start, doc) {
var result = (doc == null ? document : doc).evaluate( xpath
, (start == null ? document : start)
, null
, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE
, null);
return (result.snapshotLength > 0 ? result.snapshotItem(0) : null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment