load plugins in alphabetical order, load main script last

This commit is contained in:
Philipp Schaefer 2014-04-21 15:31:57 +02:00
parent 0ad03742d1
commit 41e60d5adc

View File

@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap;
public class IITC_WebViewClient extends WebViewClient { public class IITC_WebViewClient extends WebViewClient {
@ -57,11 +58,9 @@ public class IITC_WebViewClient extends WebViewClient {
private void loadScripts(final IITC_WebView view) { private void loadScripts(final IITC_WebView view) {
final List<String> scripts = new LinkedList<String>(); final List<String> scripts = new LinkedList<String>();
scripts.add("script" + DOMAIN + "/total-conversion-build.user.js");
// get the plugin preferences // get the plugin preferences
final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mIitc); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mIitc);
final Map<String, ?> all_prefs = sharedPref.getAll(); final TreeMap<String, ?> all_prefs = new TreeMap<String, Object>(sharedPref.getAll());
// iterate through all plugins // iterate through all plugins
for (final Map.Entry<String, ?> entry : all_prefs.entrySet()) { for (final Map.Entry<String, ?> entry : all_prefs.entrySet()) {
@ -80,6 +79,8 @@ public class IITC_WebViewClient extends WebViewClient {
scripts.add("script" + DOMAIN + "/user-location.user.js"); scripts.add("script" + DOMAIN + "/user-location.user.js");
} }
scripts.add("script" + DOMAIN + "/total-conversion-build.user.js");
final String js = "(function(){['" + TextUtils.join("','", scripts) + "'].forEach(function(src) {" + final String js = "(function(){['" + TextUtils.join("','", scripts) + "'].forEach(function(src) {" +
"var script = document.createElement('script');script.src = '//'+src;" + "var script = document.createElement('script');script.src = '//'+src;" +
"(document.body || document.head || document.documentElement).appendChild(script);" + "(document.body || document.head || document.documentElement).appendChild(script);" +