amitbl / blocktube

YouTube™ content blocker
GNU General Public License v3.0
942 stars 67 forks source link

[Feature request] Import Settings From "Video Blocker" Extension #22

Open jayadevanraja opened 5 years ago

jayadevanraja commented 5 years ago

I have many channels and keywords blocked with "Video Blocker" (https://addons.mozilla.org/en-GB/firefox/addon/video-blocker/). Please provide a button (or wizard) which can import/export those settings, so that I can use those settings instead of manually entering the items again in Blocktube.

ghost commented 5 years ago

Can you give me a sample file? I will write a function to import those settings.

jayadevanraja commented 5 years ago

Thanks for responding.

Video Blocker (3081 keys 5-4-2019 part 8 of 8).json.txt

Hopefully I have attached correctly. Github is not allowing ".json" files. So, I have renamed it to ".json.txt"

It is basically a file of key-value pairs, where key is the name of the channel to be blocked (and the value is "channel"), or the keyword to be blocked (and the value is "keyword"). Wildcards are also accepted.

Settings from multiple such files is accepted. The data is added to the current settings (current settings are not replaced).

ghost commented 5 years ago

I am wondering where should the keyword type go? We can create an import setting that would block all the channels given in the import and specify the format of the json. I think this would be a question for the author -> What should be the standard format of the json? type: [channels, channel_id, video_id, video] and there would be a corresponding key. Something like this.... The 'keyword' type should be manually replaced with video title to keep it generic.

{"key":"പാഞ്ചജന്യം","type":"channel"},{"key":"Cinema Company","type":"channel"},{"key":"Asia Live TV","type":"channel"},{"key":"Scene Contra","type":"channel"},{"key":"മമ്മൂട്ടി","type":"keyword"}

ghost commented 5 years ago

Sorry, I noticed there is already an import feature. I think the best idea would be to read the json that you have and save it in a different format. Then import that json

jayadevanraja commented 5 years ago

From the above comments I have a few questions: (1) What is the import Json format expected by Blocktube? Probably a python script can convert between the formats. (2) I am sorry that I didn't understand what the meaning is when you said "The 'keyword' type should be manually replaced with video title". What that setting does is that, if the title contains the corresponding keyword (inside the title), it will be blocked.

It will be more user-friendly if this extension is able to import the settings (and internally change the JSON format, as needed), so that switching between the extensions is easy. I am thinking of switching to the FOSS extension Blocktube, since "Video Blocker" is too resource hungry and proprietary.

amitbl commented 5 years ago

@shivamriky @Jayadevan-Vijayan

This is the format the extension expects to receive with the import option

{"filterData":{"channelId":["UC295-Dw_tDNtZXFeAPAW6Aw"],"channelName":["KeywordInChannelNameToBlock"],"comment":["KeywordInCommentToBlock"],"title":["KeywordInTitleToBlock"],"vidLength":[22,3333],"videoId":["hTIQz633_9w"]},"options":{"autoplay":true,"block_message":"Blocked","mixes":true,"trending":true},"uiPass":"111"}

I don't have much free time atm to continue developing new features for this extension, I only do bugfixes for now, but I will accept a pull requests that will improve it like adding support for importing "Video blocker" backups

jayadevanraja commented 5 years ago

Thanks. I don't know what the etiquette of github is, so I don't know whether this issue should be left open or closed. Thanks for the response. :)

ghost commented 5 years ago

@amitbl Could you help me to understand how are you filtering the content using the js? What I have understood so far is that you are trying to filter out the content using SPF filters which will probably either prevent the response from being displayed on the webpage. I am not sure exactly how all of this is happening. If you can name the technologies I need to understand that would be great.

Regards, Shivam Rastogi

amitbl commented 5 years ago

spfjs is what youtube's using to execute XHR requests (https://github.com/youtube/spfjs) But You don't need to know it or any other special technologies, only basic vanilla Javascript.

The addon at it's core is very basic and consists pretty much of two stages

Here are the functions to start from:

Registering hook for spfjs:

Implementation of the hooking function

Recursive object filtering function