Possible to force different subscription(s)? [ROOT]

Everything about using the stand-alone Adblock Plus app on Android
Post Reply
HB-guest

Possible to force different subscription(s)? [ROOT]

Post by HB-guest »

[Yes, I am trying to make ABP Android do something it isn't supposed to do. If I break it, I will not come crying for help.]

NOTE: I'm using the latest development version.

I tried editing the preferences XML to forcibly change my subscription to one not listing by the app. After looking like it was being attempted, I was back to EasyList. So, that approach apparently won't work.

My next idea is more involved, so I want know if the attempt is futile before I try it.

My idea/plan is to:
-- Turn off subscription updating.
-- Set up Tasker to download my subscription(s) and overwrite "files/patterns.ini".


QUESTIONS
0. Does ABP have checks in place that will prevent this?
1. Is it possible/unnecessary/futile to remove the subscription preference?
2. Do I need to delete "files/cache.js" before or after "updating"????
3. Is there a difference between the downloaded file(s) and what goes into "files/patterns.ini"?
(Sorry. I have always just used ABP and never tried to understand it.)
4. Can I simply concatenate multiple subscription files?

5. Plan C: Use the "patterns.ini" from my ABP Firefox?


100. If I can get this to "work," may I post my work here for other adventurous souls and evil doers?
loophat
Posts: 1
Joined: Fri Jan 25, 2013 7:04 am

Re: Possible to force different subscription(s)? [ROOT]

Post by loophat »

AdBlockPlus for Android is an Open Source Project.

You may answer these questions (and many more) by checking out the Mercurial repository. https://hg.adblockplus.org/adblockplusandroid/

If you are a developer, these changes can then be spread to the rest of the community.

Also, you can always 'fork' the project and post the link here.

Happy Hacking!
User avatar
Crits
Posts: 394
Joined: Mon Jan 16, 2012 11:54 am
Location: France
Contact:

Re: Possible to force different subscription(s)? [ROOT]

Post by Crits »

Most of your questions can only be addressed by an ABP dev, and I don't think they will answer here because they may be planning to eventually release this feature anyway (no ETA at the moment), so the best for you is simply to test your different assumptions.

3. They are not formatted in the same way. Just compare the two, you'll be able to spot the differences.
4. Yes, you can.
5. Compare the 2 versions of patterns.ini. If they are the same, I don't see why one shouldn't be able replace the other.

I have another suggestion:
Starting subscriptions are hardcoded in ABP for Android. So try to modify the subscription.xml file in ABP source code by replacing the URL of the default subscription you would normally get (ex: Liste FR+EasyList if you are French - if you are English, you have to modify the URLs of both EasyList and Fanboy's list) by the custom one you want.

Then build your new version of ABP for Android, if you know how to do so.
Hope it works.
Author of Liste FR, an ad-blocking subscription for French websites
User avatar
Crits
Posts: 394
Joined: Mon Jan 16, 2012 11:54 am
Location: France
Contact:

Re: Possible to force different subscription(s)? [ROOT]

Post by Crits »

I also suggested another workaround in a similar discussion here:
forum/viewtopic.php?f=1&t=12495&p=68753#p68753
Author of Liste FR, an ad-blocking subscription for French websites
HB-guest

Re: Possible to force different subscription(s)? [ROOT]

Post by HB-guest »

@loophat:
Yes. I quickly gleamed what I could from the source and issues. Multiple subscriptions, and I think "add your own", have been acknowledged, but that's in the future plans. I was just seeking a "simple" workaround until then.

[Aside: I am a strong proponent of open source, so everything was going public somewhere. And I rather hand the dev a working patch, than fork. "Competing" forks are just ... a little counter to ideal open source, but needed occasionally.]

@Crits:
I was hoping a/the dev would pop out a quick yes/no. The moderator of this forum is a/the dev.

I figured out the answer to #3 later... The code and the transformation aren't... simple. And it isn't apparent if "just shove a subscription download file here" would trigger a new ini. Hmm... this still seems worth a try.


In my specific case, adding 1 subscription (Easy+Privacy) to subscriptions.xml would be a >90% solution. I was trying to find a method that would satisfy more that just me (and probably some others). I guess I'll add an issue/request w/ "code."

Besides, I get a daily update notification (dev build), which would wipe out the APK mod, or lose updates. But after checking HG repo, I'm wondering if the updates are real or not. It isn't obvious from the changelog.


Thanks for your responses.

And thank you dev(s) all your porting effort. It is appreciated.
User avatar
Crits
Posts: 394
Joined: Mon Jan 16, 2012 11:54 am
Location: France
Contact:

Re: Possible to force different subscription(s)? [ROOT]

Post by Crits »

Glad it works ;)
The possibility to add more subscriptions to subscription.xml is great, the only downside I see is that you cannot select multiple subscriptions at once with ABP for Android.
If you want to have EasyList+EasyPrivacy+EasyList Germany for example, you would have to make yourself a filter list that combines them 3.
(careful though, make sure you remove the ! Checksum: line of these lists when you put them together).
Author of Liste FR, an ad-blocking subscription for French websites
HB-guest

Re: Possible to force different subscription(s)? YES! [ROOT]

Post by HB-guest »

Crits wrote:Glad it works ;)
Hadn't tried anything yet... but I have now, and I can report success (I think)!! (How do you tell when a Privacy filter has been hit?) [shrug] But the files are are "correct."
Crits wrote:The possibility to add more subscriptions to subscription.xml is great, the only downside I see is that you cannot select multiple subscriptions at once with ABP for Android.
"EasyPrivacy+EasyList" is a single subscription, so all is cool in that department for me.
Crits wrote:If you want to have EasyList+EasyPrivacy+EasyList Germany for example, you would have to make yourself a filter list that combines them 3. (careful though, make sure you remove the ! Checksum: line of these lists when you put them together).
Upon further inspection, and with the help of WinMerge, I discovered the mysteries of the ABP-Android "patterns.ini" file format. And then how to shoe horn in a new subscription.
  1. Replace the first 2 lines of the downloaded file. (Checksum ignored!)
  2. Before: [code][Adblock Plus 1.1] ! Checksum: ecqTBRm8zUlHYWfRly9Zrg ! Title: EasyList ! Last modified: 29 Jan 2013 19:10 UTC ! Expires: 5 days (update frequency) [/code] After: [code]# Adblock Plus preferences version=4 [Subscription] url=https://easylist-downloads.adblockplus.org/easylist.txt title=EasyList homepage=https://easylist.adblockplus.org/ lastDownload=1359492491 downloadStatus=synchronize_ok lastModified=Tue, 29 Jan 2013 19:10:56 GMT lastSuccess=1359492491 lastCheck=1359492493 expires=1360356491 softExpiration=1359949688 requiredVersion=1.1 alternativeLocations=https://ares2.org/easylist/easylist.txt;q=0.9,https://adblock.maltekraus.de/easylist/easylist.txt;q=0.3 [Subscription filters] ! Title: EasyList ! Last modified: 29 Jan 2013 19:10 UTC ! Expires: 5 days (update frequency) [/code]
  3. Escape all "[" in the filters. (Replace "[" with "\[".)
  4. So, I downloaded what I wanted, borrowed the header stuff, and modified it to match. So, my file header looked like this:
  5. [code]# Adblock Plus preferences version=4 [Subscription] url=https://easylist-downloads.adblockplus.org/easyprivacy+easylist.txt title=EasyPrivacy+EasyList homepage=https://easylist.adblockplus.org/ lastDownload=1359492491 downloadStatus=synchronize_ok lastModified=Tue, 29 Jan 2013 19:10:56 GMT lastSuccess=1359492491 lastCheck=1359492493 expires=1360356491 softExpiration=1359949688 requiredVersion=1.1 [/code]
  6. Rename the file to "patterns.ini", put it on the phone, then copy it to "/data/data/org.adblockplus.android/files". (Oh. I set subscription refresh to manual, killed ABP, and restarted ABP. I don't know if all of this was necessary. Keep reading.)
The Results!!!
  • The new file was accepted, and processed into the "cache.js" file (size increase and time stamp noticed).
  • It survived the annoying "daily update." My file was still there.
  • Needing to know... I hit the subscription update button to see what would happen. Due to some weirdness of my phone, the data connection was gone, so I received a flash telling me it could not get "https://easylist-downloads.adblockplus. ... sylist.txt".... MY FILE!!!! WOOHOO!!
  • Fixed the connection issue, and, TADA!, it updated MY subscription!!! (-backup1 is my hacked file, and the new patterns file is COMPLETELY correct.)
  • A NOTE: The UI still displays "EasyList" even though it is "EasyPrivacy+EasyList."
  • Feeling cocky, I've turned subscription updates back to periodic. Too early to tell right now.
What's next...
  1. See if (now that the Java side of things has been bypassed?) multiple subscriptions will work.
  2. Make a script to automate this. I don't know the limits of BusyBox. On a full unix system, this would be a piece of cake.
  3. ... and/or generate a Tasker App Factory APK to bundle it up and tie a bow around it.
  4. If #1 fails, then fix it with #2/#3.

*** Am I forgetting something, or overlooking something, that could be rolled into this? ***
HB-guest

Well, I'll be darned...

Post by HB-guest »

This worked! I have 3 subscriptions loaded now.

  1. Copy the code block below. This is the EXACT text I used. The "filters" don't matter.
  2. Modify the [Subscription].url, and, just for good measure, the title and homepage as well. (Save it as "Unix LF" text, or at least not "Unicode.")
  3. Copy to phone.
  4. "Easy" way: Open this file on your phone, select all, and copy. Open the patterns.ini file on /data/data, select all, and paste. Otherwise, you need to chown the file.
  5. Kill ABP at a minimum. Reboot your phone may work better.
  6. Hit the update subscription button. Unless you get an error, you should be done.
  7. (OPT) Check for a much larger patterns.ini file. Open it with HTMLViewer, then find "[Subscription]". Look right?
  8. Sit back and relax. You're done.

Code: Select all

# Adblock Plus preferences
version=4

[Subscription]
url=https://easylist-downloads.adblockplus.org/easyprivacy+easylist.txt
title=EasyPrivacy+EasyList
homepage=https://easylist.adblockplus.org/
lastDownload=1359492491
downloadStatus=synchronize_ok
lastModified=Tue, 29 Jan 2013 19:10:56 GMT
lastSuccess=1359492491
lastCheck=1359492493
expires=1360356491
softExpiration=1359949688
requiredVersion=1.1

[Subscription filters]
-xtcore.js
.sitecatalyst.js
.usertracking_script.js
.webtrekk.js
/?livehit=
/?record&key=
/__ssobj/core.js
/__utm.gif
/a.logrequest.yolx?

[Subscription]
url=https://adversity.googlecode.com/hg/Antisocial.txt
title=Antisocial
homepage=http://adversity.uk.to/
lastDownload=1359492491
downloadStatus=synchronize_ok
lastModified=Tue, 29 Jan 2013 19:10:56 GMT
lastSuccess=1359492491
lastCheck=1359492493
expires=1360356491
softExpiration=1359949688
requiredVersion=1.3.9

[Subscription filters]
###addthis
###addthisButton
###article_actions_twitter
###articleSocial
###b_facebook2
###b_twitter2
###becomefan
###becomefancont
###bf_social_fblike
###CE_follow_us

[Subscription]
url=https://easylist-downloads.adblockplus.org/malwaredomains_full.txt
title=Malwaredomains
homepage=http://malwaredomains.com/?page_id=2
lastDownload=1359492491
downloadStatus=synchronize_ok
lastModified=Tue, 29 Jan 2013 19:10:56 GMT
lastSuccess=1359492491
lastCheck=1359492493
expires=1360356491
softExpiration=1359949688
requiredVersion=1.1

[Subscription filters]
||ymcakorea.org^
||ceqycfa.cn^
||skkedu.co.kr^
||adwordanalitycs.ru^
||kotopes.cn^
||solodov.in^
||tds-info.net^
||6600.org^
||8800.org^
||herangi.com^
||sgviralscan.com^
||uin1.cn^
lakin
Posts: 2
Joined: Sat Jun 08, 2013 4:19 pm

Re: Possible to force different subscription(s)? [ROOT]

Post by lakin »

HB_:
I used your method to add a filter list and it seems to be working well - thanks very much!
The steps were quite simple:
  1. Force close AdblockPlus
  2. I used Root Explorer to edit the /data/data/org.adblockplus.android/files/patterns.ini file - long press - Open in Text Editor
  3. I only have one subscription, so I just edit the url= and title= lines for the Easylist entry
  4. Save changes - the file has been truncated but that doesn't matter
  5. Open AdblockPlus and refresh the current subscription (still called Easylist)
I checked the patterns.ini file and it had indeed updated to my list.
I tried adding a rule to block an image on a webpage and it worked.

Out of interest, I tried your multiple subscriptions idea. It seems you can get away with adding only two entries to patterns.ini above the default entry (add just the [subscription] and url= lines - adblock will fix the rest.) However, I did notice in my test that it changed the original entry from Fanboy, which I had selected in the app, to Easylist (url, homepage, and the actual filters were wrong - but the title still said Fanboy). It is obviously not a problem if Easylist is what you wanted.
I don't need this feature so stopped there, but I was thinking that might be a quick way to add multiple subscription sections to the file - you could then go back and fix the urls.
lakin
Posts: 2
Joined: Sat Jun 08, 2013 4:19 pm

Re: Possible to force different subscription(s)? [ROOT]

Post by lakin »

lakin wrote:However, I did notice in my test that it changed the original entry from Fanboy, which I had selected in the app, to Easylist (url, homepage, and the actual filters were wrong - but the title still said Fanboy).
I have just found out that Fanboy/Easylist merged, and fanboy redirects to Easylist, so this wasn't a bug.

I have tested this again and it does appear to work fine. A few notes:

When you edit the file in Root Explorer it truncates it to ~97k. This is ok for your first edit, but if you make changes after that it might completely remove some of your subscriptions. You also need to force it to update the truncated subscription (so, after it updates when you open Adblock Plus, do another refresh).

It takes Adblock Plus 5 or 10 seconds to save the patterns.ini after an update.

Rather than editing existing entries, you can get away with removing everything and just adding a few new ones, so your patterns.ini would look like this:

Code: Select all

# Adblock Plus preferences
version=4

[Subscription]
url=https://easylist-downloads.adblockplus.org/easylist.txt

[Subscription]
url=https://easylist-downloads.adblockplus.org/easyprivacy.txt

[Subscription]
url=https://easylist-downloads.adblockplus.org/easylistgermany.txt

[Subscription]
url=https://easylist-downloads.adblockplus.org/easylistitaly.txt
Mikaila
Posts: 39
Joined: Thu May 29, 2014 8:11 am

Re: Possible to force different subscription(s)? [ROOT]

Post by Mikaila »

Hello, I am not an expert so could anyone tell me if to add those modifications I need a specific program on my mobile or if I can do it directly on the app?
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Possible to force different subscription(s)? [ROOT]

Post by mapx »

Mikaila wrote:Hello, I am not an expert so could anyone tell me if to add those modifications I need a specific program on my mobile or if I can do it directly on the app?
lakin is listing the steps to do the job
forum/viewtopic.php?p=76195#p76195

and is talking about using root explorer (app)
DaveD

Re: Possible to force different subscription(s)? [ROOT]

Post by DaveD »

I've been trying for some time to get rid of the social icons and connections that appear on damn near all urls these days and finally found this thread. I followed the rather simple instructions above, and can verify that my adblockplus patterns.ini does indeed have the fanboy-social.txt loaded. But there is no difference in the way the offending urls look. On three browsers--Dolphin, Chrome, and Opera, the icons are still there, still in the way, still in my face, and if I click on the FB icon it takes me to Facebook. Nothing is blocked. Root Explorer tells me that the patterns.ini file is regularly updated. I'm running 4.4.2 rooted on a Samsung Note 2014.

What am I missing? Isn't what I am expecting the whole focus of this thread? Do my specific annoying urls have to be added by Fanboy to the list text file for them to be blocked there?

Thanks for any help.
LucasBS
Posts: 2
Joined: Fri May 20, 2016 7:20 pm

Re: Possible to force different subscription(s)? [ROOT]

Post by LucasBS »

lakin wrote:
  1. Force close AdblockPlus
  2. I used Root Explorer to edit the /data/data/org.adblockplus.android/files/patterns.ini file - long press - Open in Text Editor
  3. I only have one subscription, so I just edit the url= and title= lines for the Easylist entry
  4. Save changes - the file has been truncated but that doesn't matter
  5. Open AdblockPlus and refresh the current subscription (still called Easylist)
I checked the patterns.ini file and it had indeed updated to my list.
I tried adding a rule to block an image on a webpage and it worked.
I've tried those steps, but once I update the list inside ABP, the pattern.ini goes back to it's prior state (default easylist url and title)

ABP 1.3.359
Post Reply