From 0ba9c8c374fee2fef558f882196baa6c0f0e53ec Mon Sep 17 00:00:00 2001 From: nomandhoni-cs Date: Tue, 10 Oct 2023 19:55:33 +0600 Subject: [PATCH 1/2] :heavy_check_mark: Added all necessary files to work --- .github/workflows/production.yml | 26 ++++++++++++++ .../{Untitled design (4).png => icon128.png} | Bin ...led design (5).png => icon128_updated.png} | Bin ...Untitled design (4) (1).png => icon16.png} | Bin ... design (5) (2).png => icon16_updated.png} | Bin ...Untitled design (4) (2).png => icon48.png} | Bin ... design (5) (1).png => icon48_updated.png} | Bin content.js | 34 ++++++++++++++++++ manifest.json | 24 +++++++------ popup.html | 10 ++++++ 10 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/production.yml rename assets/logo/{Untitled design (4).png => icon128.png} (100%) rename assets/logo/{Untitled design (5).png => icon128_updated.png} (100%) rename assets/logo/{Untitled design (4) (1).png => icon16.png} (100%) rename assets/logo/{Untitled design (5) (2).png => icon16_updated.png} (100%) rename assets/logo/{Untitled design (4) (2).png => icon48.png} (100%) rename assets/logo/{Untitled design (5) (1).png => icon48_updated.png} (100%) create mode 100644 content.js create mode 100644 popup.html diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml new file mode 100644 index 0000000..49956b4 --- /dev/null +++ b/.github/workflows/production.yml @@ -0,0 +1,26 @@ +name: Bump version +on: + pull_request: + types: + - closed + branches: + - production + +jobs: + build: + if: github.event.pull_request.merged == true + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} + fetch-depth: '0' + + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.64.0 # Don't use @master or @v1 unless you're happy to test the latest version + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }} # if you don't want to set write permissions use a PAT token + WITH_V: true + PRERELEASE: true diff --git a/assets/logo/Untitled design (4).png b/assets/logo/icon128.png similarity index 100% rename from assets/logo/Untitled design (4).png rename to assets/logo/icon128.png diff --git a/assets/logo/Untitled design (5).png b/assets/logo/icon128_updated.png similarity index 100% rename from assets/logo/Untitled design (5).png rename to assets/logo/icon128_updated.png diff --git a/assets/logo/Untitled design (4) (1).png b/assets/logo/icon16.png similarity index 100% rename from assets/logo/Untitled design (4) (1).png rename to assets/logo/icon16.png diff --git a/assets/logo/Untitled design (5) (2).png b/assets/logo/icon16_updated.png similarity index 100% rename from assets/logo/Untitled design (5) (2).png rename to assets/logo/icon16_updated.png diff --git a/assets/logo/Untitled design (4) (2).png b/assets/logo/icon48.png similarity index 100% rename from assets/logo/Untitled design (4) (2).png rename to assets/logo/icon48.png diff --git a/assets/logo/Untitled design (5) (1).png b/assets/logo/icon48_updated.png similarity index 100% rename from assets/logo/Untitled design (5) (1).png rename to assets/logo/icon48_updated.png diff --git a/content.js b/content.js new file mode 100644 index 0000000..0ce3334 --- /dev/null +++ b/content.js @@ -0,0 +1,34 @@ +function hideSuggestedPosts() { + var allElements = document.querySelectorAll( + 'span.x193iq5w.xeuugli.x13faqbe.x1vvkbs.x1xmvt09.x1lliihq.x1s928wv.xhkezso.x1gmr53x.x1cpjm7i.x1fgarty.x1943h6x.xudqn12.x3x7a5m.x6prxxf.xvq8zen.xo1l8bm.xi81zsa[dir="auto"]' + ); + var suggestedElements = []; + + for (var i = 0; i < allElements.length; i++) { + var element = allElements[i]; + if (element.textContent === "Suggested for you") { + suggestedElements.push(element); + } + } + + suggestedElements.forEach(function (spanElement) { + var parentElement = spanElement.parentElement; + while (parentElement) { + if (parentElement.classList.contains("x1lliihq")) { + parentElement.remove(); + + // Update the extension icon + chrome.action.setIcon({ + path: { + 16: "images/icon16_updated.png", + 48: "images/icon48_updated.png", + 128: "images/icon128_updated.png", + }, + }); + + break; + } + parentElement = parentElement.parentElement; + } + }); +} diff --git a/manifest.json b/manifest.json index 3fa4c9f..2c01c44 100644 --- a/manifest.json +++ b/manifest.json @@ -1,20 +1,19 @@ { "manifest_version": 3, - "name": "Facebook Suggested Posts Remover", - "version": "1.0", - "description": "Remove suggested posts on Facebook after every 100px of mouse scroll.", + "name": "Facebook QuietFeed", + "version": "0.1.0", + "description": "Facebook QuietFeed: Silence the noise and distractions on your Facebook feed for a more focused browsing experience.", "permissions": [ "activeTab", "storage", - "webNavigation", - "https://www.facebook.com/" + "webNavigation" ], "action": { "default_popup": "popup.html", "default_icon": { - "16": "images/icon16.png", - "48": "images/icon48.png", - "128": "images/icon128.png" + "16": "assets/logo/icon16.png", + "48": "assets/logo/icon48.png", + "128": "assets/logo/icon128.png" } }, "content_scripts": [ @@ -28,8 +27,11 @@ } ], "icons": { - "16": "images/icon16.png", - "48": "images/icon48.png", - "128": "images/icon128.png" + "16": "assets/logo/icon16.png", + "48": "assets/logo/icon48.png", + "128": "assets/logo/icon128.png" + }, + "background": { + "service_worker": "content.js" } } \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..1f6cf98 --- /dev/null +++ b/popup.html @@ -0,0 +1,10 @@ + + + + + + Facebook QuietFeed + + + + \ No newline at end of file From d87c8b82a3502f121bc601c489ee9d7294595d6d Mon Sep 17 00:00:00 2001 From: nomandhoni-cs Date: Tue, 10 Oct 2023 20:31:28 +0600 Subject: [PATCH 2/2] Tried to fix the stack error --- content.js | 34 ---------------------------------- js/content.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 11 ++++------- 3 files changed, 52 insertions(+), 41 deletions(-) delete mode 100644 content.js create mode 100644 js/content.js diff --git a/content.js b/content.js deleted file mode 100644 index 0ce3334..0000000 --- a/content.js +++ /dev/null @@ -1,34 +0,0 @@ -function hideSuggestedPosts() { - var allElements = document.querySelectorAll( - 'span.x193iq5w.xeuugli.x13faqbe.x1vvkbs.x1xmvt09.x1lliihq.x1s928wv.xhkezso.x1gmr53x.x1cpjm7i.x1fgarty.x1943h6x.xudqn12.x3x7a5m.x6prxxf.xvq8zen.xo1l8bm.xi81zsa[dir="auto"]' - ); - var suggestedElements = []; - - for (var i = 0; i < allElements.length; i++) { - var element = allElements[i]; - if (element.textContent === "Suggested for you") { - suggestedElements.push(element); - } - } - - suggestedElements.forEach(function (spanElement) { - var parentElement = spanElement.parentElement; - while (parentElement) { - if (parentElement.classList.contains("x1lliihq")) { - parentElement.remove(); - - // Update the extension icon - chrome.action.setIcon({ - path: { - 16: "images/icon16_updated.png", - 48: "images/icon48_updated.png", - 128: "images/icon128_updated.png", - }, - }); - - break; - } - parentElement = parentElement.parentElement; - } - }); -} diff --git a/js/content.js b/js/content.js new file mode 100644 index 0000000..f6235d7 --- /dev/null +++ b/js/content.js @@ -0,0 +1,48 @@ +let lastScrollPosition = 0; +let isScrollingDown = false; + +window.addEventListener("scroll", function () { + let currentScrollPosition = window.scrollY; + + // Check if the user is scrolling down (scrolling away from the top) + if (currentScrollPosition > lastScrollPosition) { + isScrollingDown = true; + } else { + isScrollingDown = false; + } + + // Check if the user scrolled at least 100px and is scrolling down + if ( + Math.abs(currentScrollPosition - lastScrollPosition) >= 100 && + isScrollingDown + ) { + hideSuggestedPosts(); + lastScrollPosition = currentScrollPosition; + } +}); + +function hideSuggestedPosts() { + console.log("Runed"); + let allElements = document.querySelectorAll( + 'span.x193iq5w.xeuugli.x13faqbe.x1vvkbs.x1xmvt09.x1lliihq.x1s928wv.xhkezso.x1gmr53x.x1cpjm7i.x1fgarty.x1943h6x.xudqn12.x3x7a5m.x6prxxf.xvq8zen.xo1l8bm.xi81zsa[dir="auto"]' + ); + let suggestedElements = []; + + for (let i = 0; i < allElements.length; i++) { + let element = allElements[i]; + if (element.textContent === "Suggested for you") { + suggestedElements.push(element); + } + } + + suggestedElements.forEach(function (spanElement) { + let parentElement = spanElement.parentElement; + while (parentElement) { + if (parentElement.classList.contains("x1lliihq")) { + parentElement.remove(); + break; + } + parentElement = parentElement.parentElement; + } + }); +} diff --git a/manifest.json b/manifest.json index 2c01c44..538ab8b 100644 --- a/manifest.json +++ b/manifest.json @@ -22,16 +22,13 @@ "https://www.facebook.com/*" ], "js": [ - "content.js" + "js/content.js" ] } ], "icons": { - "16": "assets/logo/icon16.png", - "48": "assets/logo/icon48.png", - "128": "assets/logo/icon128.png" - }, - "background": { - "service_worker": "content.js" + "16": "assets/logo/icon16.png", + "48": "assets/logo/icon48.png", + "128": "assets/logo/icon128.png" } } \ No newline at end of file