motivanon had made one for filters, we have a custom css support now - there's a dedicated thread on /g/ check
duck made pretty cool one, another by i think someone in /gen/
Anonymous
loc-IN
>>1096
motivanon had made one for filters, we have a custom css support now - there's a dedicated thread on /g/ check
duck made pretty cool one, another by i think someone in /gen/
nepali anon
vU1ohB
20/06/25 (Fri) 16:43
No.1285
"Script" to download all the media files from a thread. Doesn't support thread watching and other features. Or even checking already downloaded files.
NOTE: Powershell
NOTE: Use if you just want to download all the files from a thread just as they are (except when multiple files with the same name exist, then a count index is prefixed in front of the title)
# edit these
$board = "b"
$thread_id = 146229
# patterns
$post_container_pattern = '<div class="post-container-group">.*'
$image_links_pattern = '<a\s+href="([^"]+)"\s+title="([^"]+)"\s+target="_blank">'
$thread_url = "https://bharatchan.com/board/$board/thread/$thread_id"
$html_content = (Invoke-WebRequest -Uri $thread_url).Content
$desired_block = [regex]::Match($html_content, $post_container_pattern).Value
$mediaFiles = [regex]::Matches($desired_block, $image_links_pattern);
# total of 2 gropus
# 0 -> full match
# 1 -> url path
# 2 -> title
foreach ($file in $mediaFiles) {
$url_path = $file.Groups[1].Value
$title = $file.Groups[2].Value
# check if file with "title" already exists.
# if it does, make a new title
if (Test-Path $title) {
$count = 1
$new_title = "$count-$title"
while (Test-Path $new_title) {
$count++
$new_title = "$count-$title"
}
$title = $new_title
}
# declare the download link variable and download the media file.
$file_url = "https://bharatchan.com" + $url_path
try {
Invoke-WebRequest -Uri $file_url -OutFile $title
Write-Host "Downloaded file: $title";
} catch {
Write-Host "Kuch hogya yaar. Debug karna padega phirse. T_T"
Write-Host "Error: $_.Exception.Message"
}
}
Feedback much appreciated.
nepali anon
loc-IN
"Script" to download all the media files from a thread. Doesn't support thread watching and other features. Or even checking already downloaded files.
NOTE: Powershell
NOTE: Use if you just want to download all the files from a thread just as they are (except when multiple files with the same name exist, then a count index is prefixed in front of the title)
[code]
# edit these
$board = "b"
$thread_id = 146229
# patterns
$post_container_pattern = '<div class="post-container-group">.*'
$image_links_pattern = '<a\s+href="([^"]+)"\s+title="([^"]+)"\s+target="_blank">'
$thread_url = "https://bharatchan.com/board/$board/thread/$thread_id"
$html_content = (Invoke-WebRequest -Uri $thread_url).Content
$desired_block = [regex]::Match($html_content, $post_container_pattern).Value
$mediaFiles = [regex]::Matches($desired_block, $image_links_pattern);
# total of 2 gropus
# 0 -> full match
# 1 -> url path
# 2 -> title
foreach ($file in $mediaFiles) {
$url_path = $file.Groups[1].Value
$title = $file.Groups[2].Value
# check if file with "title" already exists.
# if it does, make a new title
if (Test-Path $title) {
$count = 1
$new_title = "$count-$title"
while (Test-Path $new_title) {
$count++
$new_title = "$count-$title"
}
$title = $new_title
}
# declare the download link variable and download the media file.
$file_url = "https://bharatchan.com" + $url_path
try {
Invoke-WebRequest -Uri $file_url -OutFile $title
Write-Host "Downloaded file: $title";
} catch {
Write-Host "Kuch hogya yaar. Debug karna padega phirse. T_T"
Write-Host "Error: $_.Exception.Message"
}
}
[/code]
Feedback much appreciated.
Actually filters out posts. Matches for even names in replies. (Current bhch filters don't do it and we will have to wait for the next bhch update for that I guess)
Two ways to do it.
1. Download it and use it
2. Copy paste the source and stuff yourself.
Download
Link: Expires in 20 days. Normal file upload things such as Mediafire didn't work on my BSNL/Jio connection.
chrome.storage.sync.get("filterWords", (data) => {
const filterWords = data.filterWords || [];
// Check if filterWords is empty or contains only spaces
const validFilterWords = filterWords
.map(word => word.trim()) // Trim spaces around each word
.filter(word => word.length > 0); // Remove empty strings
if (validFilterWords.length > 0) {
// Function to toggle hiding of a post
const hidePost = (post) => {
// Create a placeholder image element
const placeholderImage = document.createElement("img");
placeholderImage.src = chrome.runtime.getURL("hidden.png");
placeholderImage.alt = "hidden";
placeholderImage.style.cursor = "pointer";
placeholderImage.style.width = "100px";
placeholderImage.style.height = "100px";
// Hide original post content and images
const mediaContainer = post.querySelector(".post-media-container");
if (mediaContainer) {
// Hide media container and insert placeholder image
mediaContainer.style.display = "none";
mediaContainer.parentNode.insertBefore(placeholderImage, mediaContainer);
}
const content = post.querySelector(".post-content");
if (content) content.style.display = "none";
// Set click event to unhide the post
placeholderImage.onclick = () => {
placeholderImage.remove();
if (mediaContainer) mediaContainer.style.display = "block";
if (content) content.style.display = "block";
};
};
// Check all posts and apply filtering
document.querySelectorAll(".post").forEach((post) => {
const text = post.innerText.toLowerCase();
// Only hide posts that contain any of the valid filter words
if (validFilterWords.some(word => text.includes(word.toLowerCase()))) {
hidePost(post);
}
});
}
});
Go to chrome plugins, upload and enable the plugin, stick it on the hotbar.
Set your filter words, separated by commas.
Click save.
Done!
Anonymous
RJ
icon16.png, icon48.png, icon128.png, hidden.png
#Bura Mat Dekho Bharatchan Filter (Chrome plugin)
Actually filters out posts. Matches for even names in replies. (Current bhch filters don't do it and we will have to wait for the next bhch update for that I guess)
Two ways to do it.
1. Download it and use it
2. Copy paste the source and stuff yourself.
##Download
Link: Expires in 20 days. Normal file upload things such as Mediafire didn't work on my BSNL/Jio connection.
https://limewire.com/d/beImd#RA7ncMvgnP
---------------
## Do it yourself.
Step 1: Make a folder, name it anything.
I named mine 'bharatchan-filter'
Download Picrels
Save them as:
icon16.png
icon48.png
icon128.png
hidden.png
Next, make 4 empty files, name them:
content.js
manifest.json
popup.html
popup.js
---
###content.js
[code]
chrome.storage.sync.get("filterWords", (data) => {
const filterWords = data.filterWords || [];
// Check if filterWords is empty or contains only spaces
const validFilterWords = filterWords
.map(word => word.trim()) // Trim spaces around each word
.filter(word => word.length > 0); // Remove empty strings
if (validFilterWords.length > 0) {
// Function to toggle hiding of a post
const hidePost = (post) => {
// Create a placeholder image element
const placeholderImage = document.createElement("img");
placeholderImage.src = chrome.runtime.getURL("hidden.png");
placeholderImage.alt = "hidden";
placeholderImage.style.cursor = "pointer";
placeholderImage.style.width = "100px";
placeholderImage.style.height = "100px";
// Hide original post content and images
const mediaContainer = post.querySelector(".post-media-container");
if (mediaContainer) {
// Hide media container and insert placeholder image
mediaContainer.style.display = "none";
mediaContainer.parentNode.insertBefore(placeholderImage, mediaContainer);
}
const content = post.querySelector(".post-content");
if (content) content.style.display = "none";
// Set click event to unhide the post
placeholderImage.onclick = () => {
placeholderImage.remove();
if (mediaContainer) mediaContainer.style.display = "block";
if (content) content.style.display = "block";
};
};
// Check all posts and apply filtering
document.querySelectorAll(".post").forEach((post) => {
const text = post.innerText.toLowerCase();
// Only hide posts that contain any of the valid filter words
if (validFilterWords.some(word => text.includes(word.toLowerCase()))) {
hidePost(post);
}
});
}
});
[/code]
###manifest.json
[code]
{
"manifest_version": 3,
"name": "Bura Mat Dekho: Bharatchan Filter",
"version": "1.0",
"description": "Filter posts containing specific letter combinations on bharatchan.com",
"permissions": ["storage"],
"host_permissions": ["https://bharatchan.com/*"],
"content_scripts": [
{
"matches": ["https://bharatchan.com/*"],
"js": ["content.js"]
}
],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
},
"web_accessible_resources": [
{
"resources": ["hidden.png"],
"matches": ["<all_urls>"]
}
]
}
[/code]
###popup.html
[code]
<!DOCTYPE html>
<html>
<head><title>Bharatchan Filter Settings</title></head>
<body>
<h3>Edit Filter Words</h3>
<textarea id="filterWords" rows="10" cols="30"></textarea>
<button id="saveBtn">Save</button>
<script src="popup.js"></script>
</body>
</html>
[/code]
###popup.js
[code]
document.getElementById("saveBtn").addEventListener("click", () => {
const filterWords = document.getElementById("filterWords").value.split(",");
chrome.storage.sync.set({ filterWords }, () => {
alert("Filter words saved!");
});
});
window.onload = () => {
chrome.storage.sync.get("filterWords", (data) => {
document.getElementById("filterWords").value = data.filterWords ? data.filterWords.join(",") : "";
});
};
[/code]
Save the files, close them.
Now, your folder should look like this:
-/bharatchan-filter/
|
|/content.js
|/hidden.png
|/icon16.png
|/icon48.png
|/icon128.png
|/manifest.json
|/popup.html
|/popup.js
zip them all to get:
bharatchan-filter.zip
Go to chrome plugins, upload and enable the plugin, stick it on the hotbar.
Set your filter words, separated by commas.
Click save.
Done!