Dancylove
  • Home
  • General news
  • Recreational sports
    How to Take a Screenshot on Windows, Mac, Phone or Tablet

    How to Take a Screenshot on Windows, Mac, Phone or Tablet

    how to fix 640×480 video mode

    how to fix 640×480 video mode

    Instructions on how to download Recuva software to get back lost files

    Instructions on how to download Recuva software to get back lost files

    Summary of 200 Keyboard Shortcuts for Windows Users

    Summary of 200 Keyboard Shortcuts for Windows Users

    How to see wood messages on messenger?

    How to see wood messages on messenger?

    How to fix system error client League of Legends

    How to fix system error client League of Legends

    Instructions Automatically increase views for tiktok

    Instructions Automatically increase views for tiktok

    How to fix m.youtube keep showing as mobile version on a PC browser?

    How to fix m.youtube keep showing as mobile version on a PC browser?

    How to create a quick launcher application, in a very beautiful circle in Windows 10?

    How to create a quick launcher application, in a very beautiful circle in Windows 10?

  • Technology tips
  • Recrational sports
  • Home
  • General news
  • Recreational sports
    How to Take a Screenshot on Windows, Mac, Phone or Tablet

    How to Take a Screenshot on Windows, Mac, Phone or Tablet

    how to fix 640×480 video mode

    how to fix 640×480 video mode

    Instructions on how to download Recuva software to get back lost files

    Instructions on how to download Recuva software to get back lost files

    Summary of 200 Keyboard Shortcuts for Windows Users

    Summary of 200 Keyboard Shortcuts for Windows Users

    How to see wood messages on messenger?

    How to see wood messages on messenger?

    How to fix system error client League of Legends

    How to fix system error client League of Legends

    Instructions Automatically increase views for tiktok

    Instructions Automatically increase views for tiktok

    How to fix m.youtube keep showing as mobile version on a PC browser?

    How to fix m.youtube keep showing as mobile version on a PC browser?

    How to create a quick launcher application, in a very beautiful circle in Windows 10?

    How to create a quick launcher application, in a very beautiful circle in Windows 10?

  • Technology tips
  • Recrational sports
No Result
View All Result
Dancylove
No Result
View All Result
Home Technology tips

Instructions for self-writing the extension to block facebook ads in 5p

Instructions for self-writing the extension to block facebook ads in 5p

by admin
January 17, 2021
in Technology tips
483 15
0
Instructions for self-writing the extension to block facebook ads in 5p
747
SHARES
3.6k
VIEWS
Share on FacebookShare on Twitter
* Guide to write the extension to block facebook ads in 5p
for everyone who knows how to use facebook on a laptop With
only about
10 lines of code, you can create your own Facebook ad blocking extension

1. Begin

chrome_developers extension – Get familiar with the code
create 1 folder [facebook_block_ads]
Create a manifest.json file in the directory
create a content.js file in the directory

# directory structure

facebook_block_ads
– manifest.json
– content.js

2. What does Facebook_block_ads need?

is as simple as deleting posts with sponsored | sponsored posts
It is also possible to replace the post position with what you want

3. What does the extension need?

1 File manifest.json to declare, 1 File content.js to delete articles with ads
What do we declare in manifest.json

{
  "name": "Getting Started Example",
  "version": "1.0",
  "description": "Build an Extension!",
  "content_scripts": [
   {
     "matches": ["https://*.facebook.com/*"],
     "js": ["content.js"],
     "run_at": "document_end"
   }],
  "manifest_version": 2
}

Explain a bit about content_scripts declaration
– matches: declare the url in which the content.js file can function
– js: declare file content.js 🙂

Idea for writing content.js files
– Retrieve all articles currently displayed on the screen
– find articles with [Sponsored] advertising content
– Delete those posts
What is in the content.js file

window.onscroll = function (e) {
// called when the window is scrolled.
    let elements = document.querySelectorAll("[data-pagelet='FeedUnit_{n}']");
    elements.forEach(function (ele, i) {
        if (elements[i].innerHTML.indexOf("Được tài trợ") !== -1) {
            elements[i].remove();
        }
    })
}

# explain a bit about the content.js file

let elements = document.querySelectorAll (“[data-pagelet = ‘FeedUnit_ {n}’]”); // find all posts
elements.forEach (function (ele, i) {… // loop to cycle through posts
if (elements [i] .innerHTML.indexOf (“Sponsored”)! == -1) {… // find the post containing the advertisement
elements [i] .remove (); // delete those posts
window.onscroll // detected scrolling

Link: https://github.com/dangtinh-dev/extensions/tree/master/block-ads-facebook?

 

Previous Post

How to fix usb windows 10 clean install?

Next Post

Detailed instructions on how to reload the firmware for the defective USB

admin

admin

Next Post
Detailed instructions on how to reload the firmware for the defective USB

Detailed instructions on how to reload the firmware for the defective USB

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular

    About

    • Home
    • Contact
    • About
    • Policy

    Recent hot posts

    • How to Take a Screenshot on Windows, Mac, Phone or Tablet
    • how to fix 640×480 video mode
    • Instructions on how to download Recuva software to get back lost files
    • Summary of 200 Keyboard Shortcuts for Windows Users
    • How to see wood messages on messenger?
    February 2021
    M T W T F S S
    1234567
    891011121314
    15161718192021
    22232425262728
    « Jan    

    DMCA.com Protection Status

    © 2021 JNews - Premium WordPress news & magazine theme by Jegtheme.

    No Result
    View All Result
    • Home
    • General news
    • Recreational sports
    • Technology tips
    • Recrational sports

    © 2021 JNews - Premium WordPress news & magazine theme by Jegtheme.

    Login to your account below

    Forgotten Password?

    Fill the forms bellow to register

    All fields are required. Log In

    Retrieve your password

    Please enter your username or email address to reset your password.

    Log In