Add a Copy Adlists button in the UI

Sharing adlists is a common practice, but getting the adlists from the UI is cumbersome. Trying to drag select and copy the table from the Adlists page results in a lot of cruft and whitespace being copied.

I propose a "copy adlists" button be added above the table that copies the adlist to the clipboard with a space in between each URL. This would allow the string to be easily pasted into "add a new list" field since that's the format it expects for multiple urls.

The button should always be visible but it should respect the checkboxes that indicate selected rows in the table. This would allow only the selected rows to be copied. To make this clear, the text should change from "copy all adlists" when nothing is selected to "copy selected adlists" when at least one row is selected.

This feature could be further embellished later with a modal popup that displays a textarea preview of what will be copied. From there it could be copied manually, or with a clipboard button, or even downloaded as a file.

In the meantime, you can display your adlists in text format (one per line) with the following SQL commands:

Display all adlists (active or not):

pihole-FTL sqlite3 /etc/pihole/gravity.db "SELECT address FROM adlist"

Display only active adlists:

pihole-FTL sqlite3 /etc/pihole/gravity.db "SELECT address FROM adlist where enabled=1"

From the screen output, copy/save/paste as desired.

Just to throw a web-based alternative solution out there....

I've used this chrome extension in the past for working with extracting data from HTML tables:

Thanks. I know there are workarounds; I wound up using a querySelector, in fact. However, a bulk export feature like this would be complimentary to the bulk import feature we already have.

I'd be happy to attempt to contribute it.

It would kind of duplicate the Teleporter feature which can preserve much more than only the addresses (enabled/groups/comments/...) so we'd have to reconsider if there is really an advantage. Note that Teleporter can be restricted to only partially import/restore data from the imported backup files.

We'd definitely be happy to review and merge it if we all agree that this is a useful new feature and does more than duplicating parts of the existing Teleporter functionality :slight_smile:

If you decide you can work on this, please base your code on branch development-v6 of the currently running Pi-hole v6.0 beta as any new code added to the existing v5.x code would probably get lost as no further v5.x release is planned at this point.

I think it does add new functionality. Teleporter is more of a backup utility. What I'm proposing is a way of easily grabbing data from tables (specifically the adlists right now) so it can be shared in Discord or posted in a guide.

I think it would be very useful to add two utils; one that can copy to the clipboard and another that can create a file for download in the client. These would be useful on nearly every table for either quickly copying the main data, or exporting something like a CSV file. Again, both more easily shared than a teleporter backup.

Thanks. Is there any development guide for getting pihole running locally from source?

Once you have followed the simple instructions on the blog post, you will have all the necessary source code available (I don't think we need to tinker FTL's source code, instructions are here, otherwise). The web code will be in /var/www/html/admin on your Pi-hole. You will have to change the git origin to your own fork or add a new git upstream, there are thousands of guides online, I don't think you need a specific one, e.g. How to move to a fork after cloning · GitHub (but with development-v6 instead of master branch)