Added Statistics unblocking.
This commit is contained in:
parent
28c6fd36c8
commit
b9cbd9723e
@ -1,3 +1,5 @@
|
||||
# RT Silver Background
|
||||
|
||||
chrome.runtime.onInstalled.addListener ->
|
||||
chrome.declarativeContent.onPageChanged.removeRules undefined, ->
|
||||
chrome.declarativeContent.onPageChanged.addRules [
|
||||
@ -10,3 +12,29 @@ chrome.runtime.onInstalled.addListener ->
|
||||
actions: [ new chrome.declarativeContent.ShowPageAction() ]
|
||||
}
|
||||
]
|
||||
|
||||
killswitch = true
|
||||
script_src = ''
|
||||
|
||||
chrome.runtime.onMessage.addListener (request, sender, sendResponse) ->
|
||||
if request.method is "get_script_src"
|
||||
killswitch = false
|
||||
sendResponse script_src
|
||||
else
|
||||
sendResponse {}
|
||||
|
||||
|
||||
# Prevent statistics_history script from loading
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
(details) ->
|
||||
console.log 'Cock-blocked! %o', details
|
||||
script_src = details.url
|
||||
return {cancel: killswitch}
|
||||
,
|
||||
{
|
||||
urls: [
|
||||
"*://*.cloudfront.net/*/statistics_history-*"
|
||||
]
|
||||
},
|
||||
["blocking"]
|
||||
)
|
||||
|
@ -1,6 +1,9 @@
|
||||
console.log 'RT Silver'
|
||||
# RT Silver
|
||||
# @author Markus Birth <markus@birth-online.de>
|
||||
|
||||
cleanElement = (e) ->
|
||||
console.log 'RT Silver Main'
|
||||
|
||||
cleanElement = (e) ->
|
||||
elem = document.getElementById e
|
||||
elem?.innerHTML = ''
|
||||
|
||||
@ -18,8 +21,8 @@ Godmode.text = '''
|
||||
console.log(\'Found user: %o\', user);
|
||||
user.is_gold_user = true;
|
||||
user.is_beta_tester = true;
|
||||
user.status = \'gold\';
|
||||
user.user_type = \'gold\';
|
||||
user.status = \'gold.paid\';
|
||||
user.user_type = \'gold.paid\';
|
||||
} else {
|
||||
if (god_attempts < 100) {
|
||||
console.log(\'Retrying...\');
|
||||
@ -94,22 +97,31 @@ if nav_tabs.length > 0
|
||||
nav_tabs[0].children[2].className = 'tab_friends last'
|
||||
nav_tabs[0].children[2].innerHTML = nav_tabs[0].children[2].children[0].innerHTML
|
||||
|
||||
# query script to inject and inject it
|
||||
chrome.extension.sendMessage {method: "get_script_src"}, (response) ->
|
||||
if response isnt ""
|
||||
console.log 'Document src to load: %o', response
|
||||
head = document.getElementsByTagName 'head'
|
||||
|
||||
# reload javascript
|
||||
document.reloadJS = ->
|
||||
scripts = document.getElementsByTagName 'script'
|
||||
for s in scripts
|
||||
if s.src.indexOf('statistics_history') isnt -1
|
||||
console.log 'Found script: %o', s
|
||||
head = document.getElementsByTagName 'head'
|
||||
newScript = document.createElement 'script'
|
||||
newScript.type = 'text/javascript'
|
||||
newScript.src = s.src
|
||||
s.parentNode.removeChild s
|
||||
cleanElement 'chart_1_js'
|
||||
cleanElement 'chart_1_js_legend'
|
||||
cleanElement 'chart_1_js_control'
|
||||
head[0].appendChild newScript
|
||||
break
|
||||
newScript = document.createElement 'script'
|
||||
newScript.type = 'text/javascript'
|
||||
newScript.innerText = '
|
||||
window.chart_1_configuration.period_end = (new Date).start().getTime();
|
||||
window.chart_1_backup = window.chart_1_configuration;
|
||||
console.log("Backup: %o", window.chart_1_backup);
|
||||
|
||||
#setTimeout('document.reloadJS();', 3000);
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
newScript = document.createElement("script");
|
||||
newScript.type = "text/javascript";
|
||||
newScript.src = "' + response + '?blafasel";
|
||||
newScript.onload = function() {
|
||||
console.log("Script loaded! Backup CFG: %o", window.chart_1_backup);
|
||||
window.chart_1_configuration = window.chart_1_backup;
|
||||
console.log("Chart 1 CFG: %o", window.chart_1_configuration);
|
||||
};
|
||||
head.appendChild(newScript);
|
||||
'
|
||||
head[0].appendChild newScript
|
||||
console.log 'Script appended.'
|
||||
else
|
||||
console.log 'Got no script to load.'
|
||||
|
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "RT Silver",
|
||||
"version": "2014.10.29",
|
||||
"version": "2014.10.31",
|
||||
"manifest_version": 2,
|
||||
"description": "Enables a few Gold features on Runtastic",
|
||||
"homepage_url": "https://github.com/mbirth/rtsilver",
|
||||
"background": {
|
||||
"scripts": [ "background.js" ],
|
||||
"persistent": false
|
||||
"persistent": true
|
||||
},
|
||||
"page_action": {
|
||||
"default_title": "RT Silver",
|
||||
@ -18,13 +18,20 @@
|
||||
},
|
||||
"permissions": [
|
||||
"declarativeContent",
|
||||
"tabs", "https://www.runtastic.com/*"
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"tabs", "*://www.runtastic.com/", "*://*.cloudfront.net/"
|
||||
],
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://www.runtastic.com/*"],
|
||||
"js": ["content.js"],
|
||||
"run_at": "document_idle"
|
||||
},
|
||||
{
|
||||
"matches": ["https://www.runtastic.com/*"],
|
||||
"js": ["prepare.js"],
|
||||
"run_at": "document_start"
|
||||
}
|
||||
],
|
||||
"icons": {
|
||||
|
48
src/prepare.coffee
Normal file
48
src/prepare.coffee
Normal file
@ -0,0 +1,48 @@
|
||||
# RT Silver Prepare
|
||||
|
||||
console.log 'RT Silver prepare'
|
||||
|
||||
s = document.createElement 'script'
|
||||
s.innerText = '
|
||||
window.chart_1_configuration = {
|
||||
users: [],
|
||||
sport_types: [1],
|
||||
field: "count",
|
||||
compare: "",
|
||||
period: "day",
|
||||
period_end: (new Date).value,
|
||||
kind: 0,
|
||||
initial_expand: "yes",
|
||||
container: "#chart_1_js",
|
||||
instance: {},
|
||||
lock: !1
|
||||
};
|
||||
|
||||
window.chart_2_configuration = {
|
||||
users: [],
|
||||
sport_types: [1],
|
||||
field: "count",
|
||||
compare: "",
|
||||
period: "day",
|
||||
period_end: (new Date).value,
|
||||
kind: 1,
|
||||
initial_expand: "yes",
|
||||
container: "#chart_2_js",
|
||||
instance: {},
|
||||
lock: !1
|
||||
};
|
||||
'
|
||||
|
||||
(document.head or document.documentElement).appendChild s
|
||||
|
||||
#console.log 'This is the document: %o', document.documentElement
|
||||
#console.log 'HEAD at: %o', document.documentElement.indexOf('<head')
|
||||
|
||||
# remove javascript to run later
|
||||
#scripts = document.getElementsByTagName 'script'
|
||||
#for s in scripts
|
||||
# if s.src.indexOf('statistics_history') isnt -1
|
||||
# console.log 'Found script: %o', s
|
||||
# document.rtsilver.script_src = s.src
|
||||
# s.parentNode.removeChild s
|
||||
# break
|
Reference in New Issue
Block a user