增加hash链接转magnet
This commit is contained in:
@@ -1047,7 +1047,7 @@ public class MainActivity extends Activity {
|
||||
istream.close();
|
||||
ostream.close();
|
||||
return s;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
Log.e(Thread.currentThread().getStackTrace()[2] + "", "" + e);
|
||||
return s;
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ public class MainActivity extends Activity {
|
||||
void ADBlock() {
|
||||
String s = readFile("blockrules");
|
||||
//Log.e(Thread.currentThread().getStackTrace()[2] + "", "" + s);
|
||||
if(!s.equals("")) {
|
||||
if (!s.equals("")) {
|
||||
// if (s.endsWith(",")) {
|
||||
// s = s.substring(0, s.length() - 1);
|
||||
// }
|
||||
@@ -1075,6 +1075,11 @@ public class MainActivity extends Activity {
|
||||
list_webView.get(currentPage).loadUrl(js);
|
||||
}
|
||||
|
||||
void hashToMagnet(){
|
||||
String js = "javascript:var a=document.getElementsByTagName('a');for(i=0;i<a.length;i++){if(a[i].textContent.indexOf('?hash=')!=-1){var hash=a[i].textContent.substring(a[i].textContent.indexOf('?hash=')+6);a[i].textContent='magnet:?xt=urn:btih:'+hash;}if(a[i].href.indexOf('?hash=')!=-1){var hash=a[i].href.substring(a[i].href.indexOf('?hash=')+6);a[i].href='magnet:?xt=urn:btih:'+hash;}}";
|
||||
list_webView.get(currentPage).loadUrl(js);
|
||||
}
|
||||
|
||||
// 调用系统下载,https://www.jianshu.com/p/6e38e1ef203a
|
||||
private void downloadBySystem(String surl, String contentDisposition, String mimeType, String path, String fileName) {
|
||||
// 指定下载地址
|
||||
@@ -1339,12 +1344,15 @@ public class MainActivity extends Activity {
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
super.onProgressChanged(view, newProgress);
|
||||
pgb1.setProgress(newProgress);
|
||||
|
||||
if (sharedPreferences.getBoolean("switch_adBlock", false)) {
|
||||
ADBlock();
|
||||
}
|
||||
|
||||
if (sharedPreferences.getBoolean("switch_gifBlock", false)) {
|
||||
GIFBlock();
|
||||
}
|
||||
|
||||
if (sharedPreferences.getBoolean("switch_iframeBlock", false)) {
|
||||
if (view.getUrl() != null) {
|
||||
if (!view.getUrl().contains("baidu.com")) {
|
||||
@@ -1352,6 +1360,11 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sharedPreferences.getBoolean("switch_hashToMagnet", false)) {
|
||||
hashToMagnet();
|
||||
}
|
||||
|
||||
// 链接关键字屏蔽
|
||||
if (sharedPreferences.getBoolean("switch_filter", false)) {
|
||||
String sf = sharedPreferences.getString("filter", "");
|
||||
@@ -1361,6 +1374,7 @@ public class MainActivity extends Activity {
|
||||
view.loadUrl(js);
|
||||
}
|
||||
}
|
||||
|
||||
// 链接关键字高亮
|
||||
if (sharedPreferences.getBoolean("switch_highlight", false)) {
|
||||
String shl = sharedPreferences.getString("highlight", "");
|
||||
@@ -1370,6 +1384,7 @@ public class MainActivity extends Activity {
|
||||
view.loadUrl(js);
|
||||
}
|
||||
}
|
||||
|
||||
//图片宽度超出父元素适应父元素
|
||||
if (sharedPreferences.getBoolean("switch_shrink", false)) {
|
||||
String js = "javascript:var imgs=document.getElementsByTagName('img');for(var i=0;i<imgs.length;i++){if(imgs[i].parentNode.clientWidth > 0){if(imgs[i].clientWidth>imgs[i].parentNode.clientWidth){imgs[i].width=imgs[i].parentNode.clientWidth;}}}";
|
||||
|
||||
Reference in New Issue
Block a user