xkcd (en)

Plasma Comic Sources

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

5
7.8

z3ntu

2 years ago

Broken, please fix :)

Report

TuxmAL

2 years ago

Hi, I've noted a change in xkcd.com site, gone full https now. Here are the fixes needed to patch the code:
33c33
< var re = new RegExp("Permanent link to this comic: http://xkcd.com/(\\d+)/");
---
> var re = new RegExp("Permanent link to this comic: https://xkcd.com/(\\d+)/");
47c47
< comic.requestPage("http:" + match[1], comic.Image);
---
> comic.requestPage("https:" + match[1], comic.Image);

a couple of fix again makes ' and " in additionalText looks like quote and double quote:
56c56,57
< comic.additionalText = match[2];
---
> var additionalTxt = match[2];
> comic.additionalText = additionalTxt.replace(/quot;/g, "\"").replace(/'/g, "'");
thanks!

Report

TuxmAL

2 years ago

ops! last patch is
56c56,57
< comic.additionalText = match[2];
---
> var additionalTxt = match[2];
> comic.additionalText = additionalTxt.replace(/quot;/g, "\"").replace(/&'/g, "'");

Report

TuxmAL

2 years ago

ugh! Last replace contains / & # 3 9 ;/ (remove spaces between chars).

Report

C

mfuchs

2 years ago

Thanks for your work! I updated the comic.

Report

TuxmAL

2 years ago

You are welcome!
Thanks for your work, it has been a good source to learn comics plugin!

Report

cbxAmadyne

4 years ago

The original code does not handle empty "title" and "alt" tags to well. This patch fixes that as well:http://download.amadyne.net/xkcd-main-2015-04.patch

Quote:
--- main.es 2009-02-01 03:40:16.000000000 +0100
+++ main_new.es 2015-04-02 08:26:04.215609602 +0200
@@ -41,10 +41,10 @@
}
}
if (id == comic.Page) {
- var re = new RegExp("<img src=\"(http://imgs.xkcd.com/comics/[^\"]+)\"");
+ var re = new RegExp("<img src=\"(//imgs\.xkcd\.com/comics/[^\"]+)\"");
var match = re.exec(data);
if (match != null) {
- comic.requestPage(match[1], comic.Image);
+ comic.requestPage("http:" + match[1], comic.Image);
} else {
comic.error();
return;
@@ -49,12 +49,15 @@
comic.error();
return;
}
-
//find the tooltip and the strip title of the comic
- re = new RegExp("src=\"http://imgs.xkcd.com/comics/.+\" title=\"([^\"]+)\" alt=\"([^\"]+)\"");
+ re = new RegExp("<img src=\"(//imgs\.xkcd\.com/comics/[^\"]+)\" title=\"([^\"]+)\"");
+ match = re.exec(data);
+ if (match != null) {
+ comic.additionalText = match[2];
+ }
+ re = new RegExp("<img src=\"(//imgs\.xkcd\.com/comics/[^\"]+)\".+alt=\"([^\"]+)\"");
match = re.exec(data);
if (match != null) {
- comic.additionalText = match[1];
comic.title = match[2];
}
}

Report

C

mfuchs

4 years ago

Thanks for the patch. :) I updated xkcd using your changes.

Report

cbxAmadyne

4 years ago

xkcd.com has updated the image link to no longer contain "http:"

Quote:
--- main_new.es 2015-04-01 17:35:10.992105603 +0200
+++ main.es 2009-02-01 03:40:16.000000000 +0100
@@ -41,10 +41,10 @@
}
}
if (id == comic.Page) {
- var re = new RegExp("<img src=\"(//imgs.xkcd.com/comics/[^\"]+)\"");
+ var re = new RegExp("<img src=\"(http://imgs.xkcd.com/comics/[^\"]+)\"");
var match = re.exec(data);
if (match != null) {
- comic.requestPage("http:" + match[1], comic.Image);
+ comic.requestPage(match[1], comic.Image);
} else {
comic.error();
return;

Report

quazgar

4 years ago

Please have a look at KDE bug #333063 https://bugs.kde.org/show_bug.cgi?id=333063

For some comics this great plugin crashes the Plasma Desktop.

Report

12345678910
43
product-maker weearc May 27 2017 8 great
product-maker z3ntu Dec 21 2016 8 great
product-maker quazgar Sep 04 2014 8 great
product-maker bewatched Nov 11 2010 3 bad
product-maker XxtjaxX Oct 11 2010 3 bad
product-maker gildor Oct 10 2010 3 bad
product-maker adz21c Sep 23 2010 3 bad
product-maker Count:174 Rating: 7.85
File (click to download) Version Description Downloads Date Filesize DL OCS-Install
Pling
*Needs ocs-url or ocs-store to install things
Details
license
version
1.0
updated Feb 10 2017
added Oct 24 2008
downloads today
45
page views today 5
+