Merge branch 'master' of https://github.com/jonatkins/ingress-intel-total-conversion
This commit is contained in:
commit
bfff03becd
5
build.py
5
build.py
@ -247,8 +247,6 @@ if buildMobile:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/total-conversion-build.user.js")
|
shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/total-conversion-build.user.js")
|
||||||
# copy the user location script into the mobile folder.
|
|
||||||
shutil.copy(os.path.join(outDir,"user-location.user.js"), "mobile/assets/user-location.user.js")
|
|
||||||
# also copy plugins
|
# also copy plugins
|
||||||
try:
|
try:
|
||||||
shutil.rmtree("mobile/assets/plugins")
|
shutil.rmtree("mobile/assets/plugins")
|
||||||
@ -260,6 +258,9 @@ if buildMobile:
|
|||||||
'force-https*', 'privacy-view*', 'speech-search*',
|
'force-https*', 'privacy-view*', 'speech-search*',
|
||||||
'basemap-cloudmade*', 'scroll-wheel-zoom-disable*'))
|
'basemap-cloudmade*', 'scroll-wheel-zoom-disable*'))
|
||||||
|
|
||||||
|
# copy the user location script into the mobile folder.
|
||||||
|
shutil.copy(os.path.join(outDir,"user-location.user.js"), "mobile/assets/plugins/user-location.user.js")
|
||||||
|
|
||||||
|
|
||||||
if buildMobile != 'copyonly':
|
if buildMobile != 'copyonly':
|
||||||
# now launch 'ant' to build the mobile project
|
# now launch 'ant' to build the mobile project
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.cradle.iitc_mobile"
|
package="com.cradle.iitc_mobile"
|
||||||
android:versionCode="52"
|
android:versionCode="53"
|
||||||
android:versionName="0.7.2">
|
android:versionName="0.7.3">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="14"
|
android:minSdkVersion="14"
|
||||||
|
@ -129,8 +129,6 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
js = js.replace("window.showLayerChooser = true;",
|
js = js.replace("window.showLayerChooser = true;",
|
||||||
"window.showLayerChooser = false");
|
"window.showLayerChooser = false");
|
||||||
}
|
}
|
||||||
// add all plugins to the script...inject plugins + main script simultaneously
|
|
||||||
js += parsePlugins();
|
|
||||||
|
|
||||||
// IITC expects to be injected after the DOM has been loaded completely.
|
// IITC expects to be injected after the DOM has been loaded completely.
|
||||||
// since it is injected with the onPageFinished() event, no further delay is necessary.
|
// since it is injected with the onPageFinished() event, no further delay is necessary.
|
||||||
@ -151,6 +149,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
|| url.startsWith("https://www.ingress.com/intel")) {
|
|| url.startsWith("https://www.ingress.com/intel")) {
|
||||||
Log.d("iitcm", "injecting iitc..");
|
Log.d("iitcm", "injecting iitc..");
|
||||||
view.loadUrl("javascript: " + this.mIitcScript);
|
view.loadUrl("javascript: " + this.mIitcScript);
|
||||||
|
loadPlugins(view);
|
||||||
}
|
}
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
}
|
}
|
||||||
@ -166,14 +165,12 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
//((IITC_Mobile) mContext).onReceivedLoginRequest(this, view, realm, account, args);
|
//((IITC_Mobile) mContext).onReceivedLoginRequest(this, view, realm, account, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse all enabled iitc plugins
|
public void loadPlugins(WebView view) {
|
||||||
// returns a string containing all plugins without their wrappers
|
|
||||||
public String parsePlugins() {
|
|
||||||
String js = "";
|
|
||||||
// get the plugin preferences
|
// get the plugin preferences
|
||||||
SharedPreferences sharedPref = PreferenceManager
|
SharedPreferences sharedPref = PreferenceManager
|
||||||
.getDefaultSharedPreferences(mContext);
|
.getDefaultSharedPreferences(mContext);
|
||||||
boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", false);
|
boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", false);
|
||||||
|
String path = (dev_enabled) ? mIitcPath + "dev/plugins/" : "plugins/";
|
||||||
|
|
||||||
Map<String, ?> all_prefs = sharedPref.getAll();
|
Map<String, ?> all_prefs = sharedPref.getAll();
|
||||||
|
|
||||||
@ -181,39 +178,32 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
for (Map.Entry<String, ?> entry : all_prefs.entrySet()) {
|
for (Map.Entry<String, ?> entry : all_prefs.entrySet()) {
|
||||||
String plugin = entry.getKey();
|
String plugin = entry.getKey();
|
||||||
if (plugin.endsWith("user.js") && entry.getValue().toString().equals("true")) {
|
if (plugin.endsWith("user.js") && entry.getValue().toString().equals("true")) {
|
||||||
// load default iitc plugins
|
|
||||||
if (!plugin.startsWith(mIitcPath)) {
|
if (!plugin.startsWith(mIitcPath)) {
|
||||||
|
// load default iitc plugins
|
||||||
Log.d("iitcm", "adding plugin " + plugin);
|
Log.d("iitcm", "adding plugin " + plugin);
|
||||||
if (dev_enabled)
|
loadJS(path + plugin, !dev_enabled, view);
|
||||||
js += this.removePluginWrapper(mIitcPath + "dev/plugins/"
|
|
||||||
+ plugin, false);
|
|
||||||
else
|
|
||||||
js += this.removePluginWrapper("plugins/" + plugin, true);
|
|
||||||
// load user iitc plugins
|
|
||||||
} else {
|
} else {
|
||||||
|
// load user iitc plugins
|
||||||
Log.d("iitcm", "adding user plugin " + plugin);
|
Log.d("iitcm", "adding user plugin " + plugin);
|
||||||
js += this.removePluginWrapper(plugin, false);
|
loadJS(plugin, false, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inject the user location script if enabled in settings
|
// inject the user location script if enabled in settings
|
||||||
if (sharedPref.getBoolean("pref_user_loc", false))
|
if (sharedPref.getBoolean("pref_user_loc", false))
|
||||||
js += parseTrackingPlugin(dev_enabled);
|
loadJS(path + "user-location.user.js", !dev_enabled, view);
|
||||||
|
|
||||||
return js;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String parseTrackingPlugin(boolean dev_enabled) {
|
// read a file into a string
|
||||||
Log.d("iitcm", "enable tracking...");
|
// load it as javascript
|
||||||
String js = "";
|
public boolean loadJS(String file, boolean asset, WebView view) {
|
||||||
// load plugin from external storage if dev mode are enabled
|
String js = fileToString(file, asset);
|
||||||
if (dev_enabled)
|
if (js.equals("false"))
|
||||||
js = this.removePluginWrapper(mIitcPath + "dev/user-location.user.js", false);
|
return false;
|
||||||
else
|
else
|
||||||
// load plugin from asset folder
|
view.loadUrl("javascript:" + js);
|
||||||
js = this.removePluginWrapper("user-location.user.js", true);
|
return true;
|
||||||
return js;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read a file into a string
|
// read a file into a string
|
||||||
@ -248,48 +238,6 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read a file into a string
|
|
||||||
// load it as javascript
|
|
||||||
// at the moment not needed, but not bad to have it in the IITC_WebViewClient API
|
|
||||||
public boolean loadJS(String file, boolean asset, WebView view) {
|
|
||||||
if (!file.endsWith("user.js"))
|
|
||||||
return false;
|
|
||||||
String js = fileToString(file, asset);
|
|
||||||
if (js.equals("false"))
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
view.loadUrl("javascript:" + js);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// iitc and all plugins are loaded at the same time
|
|
||||||
// so remove the wrapper functions and injection code
|
|
||||||
// TODO: it only works if the plugin is coded with the iitc plugin template
|
|
||||||
public String removePluginWrapper(String file, boolean asset) {
|
|
||||||
if (!file.endsWith("user.js")) return "";
|
|
||||||
String js = fileToString(file, asset);
|
|
||||||
if (js.equals("false")) return "";
|
|
||||||
js = js.replaceAll("\r\n", "\n"); //convert CR-LF pairs to LF - windows format text files
|
|
||||||
js = js.replaceAll("\r", "\n"); //convert remaining CR to LF - Mac format files(?)
|
|
||||||
String wrapper_start = "function wrapper() {";
|
|
||||||
String wrapper_end = "} // wrapper end";
|
|
||||||
String injection_code = "// inject code into site context\n" +
|
|
||||||
"var script = document.createElement('script');\n" +
|
|
||||||
"script.appendChild(document.createTextNode('('+ wrapper +')();'));\n" +
|
|
||||||
"(document.body || document.head || document.documentElement).appendChild(script);";
|
|
||||||
if (js.contains(wrapper_start) && js.contains(wrapper_end) && js.contains(injection_code)) {
|
|
||||||
js = js.replace(wrapper_start, "");
|
|
||||||
// remove the wrapper function
|
|
||||||
js = js.replace(wrapper_end, "");
|
|
||||||
// and the code injection
|
|
||||||
js = js.replace(injection_code, "");
|
|
||||||
} else {
|
|
||||||
Log.d("iitcm", "Removal of wrapper/injection code failed for " + file);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return js;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check every external resource if it’s okay to load it and maybe replace
|
// Check every external resource if it’s okay to load it and maybe replace
|
||||||
// it
|
// it
|
||||||
// with our own content. This is used to block loading Niantic resources
|
// with our own content. This is used to block loading Niantic resources
|
||||||
|
@ -75,8 +75,6 @@ Yes it is!
|
|||||||
</ul>
|
</ul>
|
||||||
Note:
|
Note:
|
||||||
<ul>
|
<ul>
|
||||||
<li>The plugins wrapper function has to be identical to all other IITC plugins (IITCm removes it via search and replace).
|
|
||||||
Alternatively, you can use the @@PLUGINSTART@@ / @@PLUGINEND@@ macros or remove the wrapper by hand.</li>
|
|
||||||
<li>The filename has to end with *.user.js.</li>
|
<li>The filename has to end with *.user.js.</li>
|
||||||
<li>If you don't know where to find your home directory: Enable dev-mode in the settings and follow the hint.</li>
|
<li>If you don't know where to find your home directory: Enable dev-mode in the settings and follow the hint.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user