Skip to content

Commit

Permalink
Fix: get images in spolier tags for QuestionableQuesting
Browse files Browse the repository at this point in the history
See: #1141
  • Loading branch information
dteviot committed Dec 22, 2023
1 parent f69669e commit abd96af
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions plugin/js/parsers/QuestionableQuestingParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,25 @@ class QuestionableQuestingParser extends Parser{
fixupImageUrls(content) {
for(let i of content.querySelectorAll("img")) {
let dataUrl = i.getAttribute("data-url");
if (i.src !== dataUrl ) {
if (dataUrl && (i.src !== dataUrl)) {
i.src = dataUrl;
i.removeAttribute("data-url");
i.removeAttribute("data-src");
}
this.cleanupMangledImageSrc(i);
}
}

if (i.src.indexOf("/threads/") < 40) //Simple check to see if early proxy link is misdirected through thread uri.
{
i.src = i.src.replace(/https:\/\/questionablequesting\.com\/threads\/[\w\-\d.]+?\/proxy\.php\?/i, "https://questionablequesting.com/proxy.php?");
cleanupMangledImageSrc(img) {
let url = new URL(img.src);
let hostname = url.hostname;
if (hostname.includes("questionablequesting")) {
let path = url.pathname;
let index = path.indexOf("/proxy.php");
if (0 < index) {
url.pathname = path.substring(index);

This comment has been minimized.

Copy link
@Kiradien

Kiradien Dec 22, 2023

Collaborator

Just an FYI here, there are images that will load on site but fail to load under this change. It should be fairly rare, however, it isn't impossible another ticket might appear for images which loaded under proxy may appear in the future.

QQ's proxy includes long term caching of images, and some number of stories hotlink to images links which require a time-limited token to access. These tokens are usually expired by the time you view the image, hence the proxy/cache method they use - You can imagine where this would be an issue. There are a number of other cases where the original image uri isn't available yet the image is shown on page.

I can't give any URLs where this is the case off the top of my head, and this solution should work for most instances.

}
img.src = url;
}
}

Expand Down

0 comments on commit abd96af

Please sign in to comment.