Added Statistics unblocking.
This commit is contained in:
parent
28c6fd36c8
commit
b9cbd9723e
@ -1,3 +1,5 @@
|
|||||||
|
# RT Silver Background
|
||||||
|
|
||||||
chrome.runtime.onInstalled.addListener ->
|
chrome.runtime.onInstalled.addListener ->
|
||||||
chrome.declarativeContent.onPageChanged.removeRules undefined, ->
|
chrome.declarativeContent.onPageChanged.removeRules undefined, ->
|
||||||
chrome.declarativeContent.onPageChanged.addRules [
|
chrome.declarativeContent.onPageChanged.addRules [
|
||||||
@ -10,3 +12,29 @@ chrome.runtime.onInstalled.addListener ->
|
|||||||
actions: [ new chrome.declarativeContent.ShowPageAction() ]
|
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,4 +1,7 @@
|
|||||||
console.log 'RT Silver'
|
# RT Silver
|
||||||
|
# @author Markus Birth <markus@birth-online.de>
|
||||||
|
|
||||||
|
console.log 'RT Silver Main'
|
||||||
|
|
||||||
cleanElement = (e) ->
|
cleanElement = (e) ->
|
||||||
elem = document.getElementById e
|
elem = document.getElementById e
|
||||||
@ -18,8 +21,8 @@ Godmode.text = '''
|
|||||||
console.log(\'Found user: %o\', user);
|
console.log(\'Found user: %o\', user);
|
||||||
user.is_gold_user = true;
|
user.is_gold_user = true;
|
||||||
user.is_beta_tester = true;
|
user.is_beta_tester = true;
|
||||||
user.status = \'gold\';
|
user.status = \'gold.paid\';
|
||||||
user.user_type = \'gold\';
|
user.user_type = \'gold.paid\';
|
||||||
} else {
|
} else {
|
||||||
if (god_attempts < 100) {
|
if (god_attempts < 100) {
|
||||||
console.log(\'Retrying...\');
|
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].className = 'tab_friends last'
|
||||||
nav_tabs[0].children[2].innerHTML = nav_tabs[0].children[2].children[0].innerHTML
|
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
|
newScript = document.createElement 'script'
|
||||||
document.reloadJS = ->
|
newScript.type = 'text/javascript'
|
||||||
scripts = document.getElementsByTagName 'script'
|
newScript.innerText = '
|
||||||
for s in scripts
|
window.chart_1_configuration.period_end = (new Date).start().getTime();
|
||||||
if s.src.indexOf('statistics_history') isnt -1
|
window.chart_1_backup = window.chart_1_configuration;
|
||||||
console.log 'Found script: %o', s
|
console.log("Backup: %o", window.chart_1_backup);
|
||||||
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
|
|
||||||
|
|
||||||
#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",
|
"name": "RT Silver",
|
||||||
"version": "2014.10.29",
|
"version": "2014.10.31",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"description": "Enables a few Gold features on Runtastic",
|
"description": "Enables a few Gold features on Runtastic",
|
||||||
"homepage_url": "https://github.com/mbirth/rtsilver",
|
"homepage_url": "https://github.com/mbirth/rtsilver",
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": [ "background.js" ],
|
"scripts": [ "background.js" ],
|
||||||
"persistent": false
|
"persistent": true
|
||||||
},
|
},
|
||||||
"page_action": {
|
"page_action": {
|
||||||
"default_title": "RT Silver",
|
"default_title": "RT Silver",
|
||||||
@ -18,13 +18,20 @@
|
|||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"declarativeContent",
|
"declarativeContent",
|
||||||
"tabs", "https://www.runtastic.com/*"
|
"webRequest",
|
||||||
|
"webRequestBlocking",
|
||||||
|
"tabs", "*://www.runtastic.com/", "*://*.cloudfront.net/"
|
||||||
],
|
],
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://www.runtastic.com/*"],
|
"matches": ["https://www.runtastic.com/*"],
|
||||||
"js": ["content.js"],
|
"js": ["content.js"],
|
||||||
"run_at": "document_idle"
|
"run_at": "document_idle"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matches": ["https://www.runtastic.com/*"],
|
||||||
|
"js": ["prepare.js"],
|
||||||
|
"run_at": "document_start"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icons": {
|
"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