Comments (2)
I guess not, unless you're willing to use my cookie file, then I could dm you my cookie file.
After looking into it more, I found that my script file may also be contributing to the issue. I may be grasping at straws and since you haven't reproduced the issue you probably won't know, but my script basically ensures the image quality is at the highest plus with cookies there would be more images and content populating the page. As such, for a huge webpage with lots of images, I'm guessing this could cause an issue since removing either my cookies or script in the command(so either less data being saved or a very large image is perhaps causing issue) won't result in the error?
edit: Manually running each part of my script on chrome and then using the single file extension seems to work though so I'm at a lost
edit2: Sorry for being a pain but setting images to a smaller size of max height of 720 fixed the issue so I am guessing large image(s) is causing issue with base64 string being too large?
Script in question(not great with javascript, but it's been doing it's job fine on other smaller pages):
// ==UserScript==
// @name Change images' resolution
// @version 1.0
// @description [SingleFile] Replace img url with a higher resolution version
// ==/UserScript==
(() => {
// Get the image element that has a src attribute and an empty alt(use to ignore profile images)
const imgElementsSelector = "img[src]:not([src=''])";
// Regex grouping[0] is the original string
// Group[1] is the entire string before =s where everything after the domain name is between 30-85 characters
// Group[2] will be used and set to 0 to obtain the max resolution of the image
const pattern = "(https:\/\/yt3\.(ggpht|googleusercontent)\.com\/.{30,85})(=[a-z]{1})(.*)";
const DELAY = 10000;
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
function unCollapse() {
// uncollapse show perks info on membership pages(to show stamps)
try {
document.querySelector("ytd-sponsorships-expandable-perks-renderer.style-scope.ytd-section-list-renderer").removeAttribute("is-collapsed");
console.log("Uncollapsed")
changeImageQuality()
} catch (error) {
console.log("Unable to find or remove show perk info button");
console.error(error);
}
}
function changeImageQuality() {
// Only want images in the content element
let content = document.getElementById("contents").getElementsByClassName("style-scope ytd-section-list-renderer")
for (let i = 0; i < content.length; i++) {
content[i].querySelectorAll(imgElementsSelector).forEach(element => {
try {
let img_src = element.getAttribute("src");
group_match = img_src.match(pattern);
new_img_src = group_match[1] + '=s0';
element.setAttribute("src", new_img_src);
} catch (error) {
console.log("Encountered Error");
console.error(error);
}
})
}
}
dispatchEvent(new CustomEvent("single-file-user-script-init"));
addEventListener("single-file-on-before-capture-request", async event => {
//Wait for the element before uncollapse
try {
waitForElm('ytd-sponsorships-expandable-perks-renderer.style-scope.ytd-section-list-renderer').then((elm) => {
console.log('Element is ready');
unCollapse()
});
} catch (error) {
console.error(error)
}
//Remove multi-image box items
try {
//remove the image icon on the bottom right of the images
document.querySelectorAll("yt-icon.style-scope.ytd-backstage-image-renderer").forEach(element => {
element.remove();
})
//remove the right arrow container and all
document.querySelectorAll("div.arrow-container.style-scope.ytd-post-multi-image-renderer").forEach(element => {
element.remove();
})
//remove the box container
document.querySelectorAll(".style-scope ytd-post-multi-image-renderer #items").forEach(element => {
element.removeAttribute("class");
})
} catch (error) {
console.log("Unable to remove multi-image box items");
console.error(error);
}
//Wait for the membership images to load in
try {
event.preventDefault();
await new Promise(resolve => setTimeout(resolve, DELAY));
} catch (error) {
console.error(error)
}
changeImageQuality()
// Wait for the page to load after the previous changes before capturing
event.preventDefault();
try {
await new Promise(resolve => setTimeout(resolve, DELAY));
} finally {
dispatchEvent(new CustomEvent("single-file-on-before-capture-response"));
}
console.log("Finished script");
return;
});
})();
from single-file-cli.
Is it possible for me to reproduce the issue?
from single-file-cli.
Related Issues (20)
- single-file-cli hangs even on `domcontentloaded` HOT 2
- Not a bug/issue, Wonder if we can get some insight/progress when running with a big url file? HOT 1
- Add an option to import settings from browser when using cli HOT 1
- TypeError: window.singlefile is undefined HOT 3
- support for web pages with charset gbk HOT 2
- Output file names when using `--urls-file` HOT 1
- unknown error: no chrome binary at "/usr/bin/chromium-browser" HOT 5
- Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed HOT 1
- Images don't get downloaded using CLI HOT 1
- Output extension should be .zip if `--compress-content --self-extracting-archive false` is used HOT 3
- Fails to run in drive root on Windows
- Can we use sessionData in CLI? HOT 6
- Unable to download alternative sizes of screen within <picture> tag
- Cannot use `--load-deferred-images-max-idle-time` with `--browser-script` option
- Implement native stealth mode HOT 3
- CLI doesn't capture Web Components HOT 7
- Changelog? HOT 1
- Executing the extension from console? HOT 2
- bypass cloudflare browser check
- Uncaught Error Error: ENAMETOOLONG: name too long, open 'xxxx' at (program) (internal/process/promises:246:10) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from single-file-cli.