Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Commit acb78ff

Browse files
authored
1.2.1 (#37)
The release of 1.2.1 version.
1 parent 99e5288 commit acb78ff

File tree

12 files changed

+11585
-11515
lines changed

12 files changed

+11585
-11515
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# 1.2.1 (18 января, 2019)
2+
3+
## Расширение
4+
5+
### Исправлено
6+
7+
- Расширение адаптировано под новую верстку сайта.
8+
9+
### Добавлено
10+
11+
- Во время создания скриншота будет скрываться админ-панель.
12+
113
# 1.2.0 (7 августа, 2018)
214

315
## Расширение

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
Расширение доступно для установки из следующих интернет-магазинов:
3838
- [Google Chrome Web Store](https://chrome.google.com/webstore/detail/2ch-helper/cdbeejpneccnfkmmmefieghgffglidmm)
3939
- [Mozilla Firefox Web Store](https://addons.mozilla.org/ru/firefox/addon/2ch-helper/)
40-
- [Opera Web Store]()
40+
- ~~Opera Web Store~~
4141

4242
1. Перейдите в один из вышеперечисленных магазинов.
4343
2. Нажмите `Установить`.

package-lock.json

Lines changed: 11447 additions & 11424 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
{
2-
"name": "2ch-helper",
3-
"version": "1.2.0",
4-
"description": "A browser extension which facilitates interaction with the imageboard 2ch.hk.",
5-
"scripts": {
6-
"watch:chromium:dev": "webpack --watch --config webpack.config.dev --env.platform=chromium --env.dontRemove=true",
7-
"watch:firefox:dev": "webpack --watch --config webpack.config.dev --env.platform=firefox --env.dontRemove=true",
8-
"build:chromium:prod": "webpack --config webpack.config.prod --env.platform=chromium",
9-
"build:chromium:dev": "webpack --config webpack.config.dev --env.platform=chromium",
10-
"build:firefox:prod": "webpack --config webpack.config.prod --env.platform=firefox",
11-
"build:firefox:dev": "webpack --config webpack.config.dev --env.platform=firefox",
12-
"zip:chromium": "bestzip ./dist/chromium.zip ./dist/chromium/*",
13-
"zip:firefox": "bestzip ./dist/firefox.zip ./dist/firefox/*",
14-
"clean": "rimraf ./dist",
15-
"clean:chromium": "rimraf ./dist/chromium ./dist/chromium.zip",
16-
"clean:firefox": "rimraf ./dist/firefox ./dist/firefox.zip",
17-
"build": "npm run build:prod",
18-
"build:prod": "npm run build:chromium:prod && npm run build:firefox:prod",
19-
"build:dev": "npm run build:chromium:dev && npm run build:firefox:dev",
20-
"zip": "npm run zip:chromium && npm run zip:firefox",
21-
"build-zip": "npm run build-zip:chromium:prod && npm run build-zip:firefox:prod",
22-
"build-zip:chromium:prod": "npm run build:chromium:prod && npm run zip:chromium",
23-
"build-zip:chromium:dev": "npm run build:chromium:dev && npm run zip:chromium",
24-
"build-zip:firefox:prod": "npm run build:firefox:prod && npm run zip:firefox",
25-
"build-zip:firefox:dev": "npm run build:firefox:dev && npm run zip:firefox"
26-
},
27-
"author": {
28-
"name": "Sergey Kuznetsov",
29-
"url": "https://github.com/Amaimersion"
30-
},
31-
"repository": {
32-
"type": "git",
33-
"url": "https://github.com/Amaimersion/2ch-helper"
34-
},
35-
"bugs": {
36-
"url": "https://github.com/Amaimersion/2ch-helper/issues"
37-
},
38-
"license": "MIT",
39-
"private": true,
40-
"dependencies": {
41-
"exif-js": "^2.3.0"
42-
},
43-
"devDependencies": {
44-
"@types/chrome": "0.0.63",
45-
"awesome-typescript-loader": "^5.2.0",
46-
"bestzip": "^1.1.4",
47-
"copy-webpack-plugin": "^4.5.2",
48-
"css-loader": "^0.28.11",
49-
"extract-text-webpack-plugin": "^4.0.0-beta.0",
50-
"html-webpack-plugin": "^3.2.0",
51-
"node-sass": "^4.9.2",
52-
"pug": "^2.0.3",
53-
"pug-loader": "^2.4.0",
54-
"remove-files-webpack-plugin": "^1.0.0",
55-
"rimraf": "^2.6.2",
56-
"sass-loader": "^6.0.7",
57-
"typescript": "^2.9.2",
58-
"validate-html-links-webpack-plugin": "^1.0.0",
59-
"webpack": "^4.15.1",
60-
"webpack-cli": "^2.1.5",
61-
"webpack-merge": "^4.1.3"
62-
}
63-
}
1+
{
2+
"name": "2ch-helper",
3+
"version": "1.2.1",
4+
"description": "A browser extension which facilitates interaction with the imageboard 2ch.hk.",
5+
"scripts": {
6+
"watch:chromium:dev": "webpack --watch --config webpack.config.dev --env.platform=chromium --env.dontRemove=true",
7+
"watch:firefox:dev": "webpack --watch --config webpack.config.dev --env.platform=firefox --env.dontRemove=true",
8+
"build:chromium:prod": "webpack --config webpack.config.prod --env.platform=chromium",
9+
"build:chromium:dev": "webpack --config webpack.config.dev --env.platform=chromium",
10+
"build:firefox:prod": "webpack --config webpack.config.prod --env.platform=firefox",
11+
"build:firefox:dev": "webpack --config webpack.config.dev --env.platform=firefox",
12+
"zip:chromium": "bestzip ./dist/chromium.zip ./dist/chromium/*",
13+
"zip:firefox": "bestzip ./dist/firefox.zip ./dist/firefox/*",
14+
"clean": "rimraf ./dist",
15+
"clean:chromium": "rimraf ./dist/chromium ./dist/chromium.zip",
16+
"clean:firefox": "rimraf ./dist/firefox ./dist/firefox.zip",
17+
"build": "npm run build:prod",
18+
"build:prod": "npm run build:chromium:prod && npm run build:firefox:prod",
19+
"build:dev": "npm run build:chromium:dev && npm run build:firefox:dev",
20+
"zip": "npm run zip:chromium && npm run zip:firefox",
21+
"build-zip": "npm run build-zip:chromium:prod && npm run build-zip:firefox:prod",
22+
"build-zip:chromium:prod": "npm run build:chromium:prod && npm run zip:chromium",
23+
"build-zip:chromium:dev": "npm run build:chromium:dev && npm run zip:chromium",
24+
"build-zip:firefox:prod": "npm run build:firefox:prod && npm run zip:firefox",
25+
"build-zip:firefox:dev": "npm run build:firefox:dev && npm run zip:firefox"
26+
},
27+
"author": {
28+
"name": "Sergey Kuznetsov",
29+
"url": "https://github.com/Amaimersion"
30+
},
31+
"repository": {
32+
"type": "git",
33+
"url": "https://github.com/Amaimersion/2ch-helper"
34+
},
35+
"bugs": {
36+
"url": "https://github.com/Amaimersion/2ch-helper/issues"
37+
},
38+
"license": "MIT",
39+
"private": true,
40+
"dependencies": {
41+
"exif-js": "^2.3.0"
42+
},
43+
"devDependencies": {
44+
"@types/chrome": "0.0.63",
45+
"awesome-typescript-loader": "^5.2.1",
46+
"bestzip": "^1.1.6",
47+
"copy-webpack-plugin": "^4.6.0",
48+
"css-loader": "^0.28.11",
49+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
50+
"html-webpack-plugin": "^3.2.0",
51+
"node-sass": "^4.11.0",
52+
"pug": "^2.0.3",
53+
"pug-loader": "^2.4.0",
54+
"remove-files-webpack-plugin": "^1.0.0",
55+
"rimraf": "^2.6.3",
56+
"sass-loader": "^6.0.7",
57+
"typescript": "^2.9.2",
58+
"validate-html-links-webpack-plugin": "^1.0.0",
59+
"webpack": "^4.15.1",
60+
"webpack-cli": "^2.1.5",
61+
"webpack-merge": "^4.1.3"
62+
}
63+
}

src/interaction/js/content/exif.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ abstract class Exif {
180180
* Defaults to `API.getThread()`.
181181
*/
182182
public static bindFigures(element: HTMLElement = API.getThread()): void {
183-
const figures = element.querySelectorAll<HTMLElement>("figure.image");
183+
const figures = element.querySelectorAll<HTMLElement>("figure.post__image");
184184

185185
figures.forEach((figure) => {
186186
this.bindFigure(figure);
@@ -200,7 +200,7 @@ abstract class Exif {
200200
}).href;
201201
const spanFileSize = API.getElement<HTMLSpanElement>({
202202
dcmnt: figure,
203-
selector: "figcaption > span.filesize",
203+
selector: "figcaption > span.post__filezise",
204204
errorMessage: "Could not find a span."
205205
});
206206

src/interaction/js/content/notifications.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class Observer {
3333
protected static observerEvent: MutationCallback = (mutations) => {
3434
for (let mutation of mutations) {
3535
for (let node of mutation.addedNodes) {
36-
if (!Observer.isNewPostNode(node as HTMLElement)) {
36+
if (!Observer.isPostNode(node as HTMLElement)) {
3737
continue;
3838
}
3939

@@ -49,15 +49,27 @@ abstract class Observer {
4949
*
5050
* @param node The node for checking.
5151
*/
52-
protected static isNewPostNode(node: HTMLElement): boolean {
52+
protected static isPostNode(node: HTMLElement): boolean {
5353
const postTags = ["div"];
5454
const postId = new RegExp(/((post)-*)/, "");
5555

5656
return (
5757
node.tagName &&
5858
postTags.includes(node.tagName.toLowerCase()) &&
59-
node.id &&
60-
postId.test(node.id.toLowerCase())
59+
(
60+
// old layout, without empty parent div.
61+
(
62+
node.id &&
63+
postId.test(node.id.toLowerCase()
64+
)) ||
65+
66+
// now all new posts is wrapped in empty div.
67+
(
68+
node.firstElementChild &&
69+
node.firstElementChild.id &&
70+
postId.test(node.firstElementChild.id.toLowerCase())
71+
)
72+
)
6173
);
6274
}
6375

@@ -67,10 +79,12 @@ abstract class Observer {
6779
* @param post The post for checking.
6880
*/
6981
protected static isReplyPost(post: HTMLElement): boolean {
70-
const replyPostClasses = ["reply-posts-marker"];
82+
const replyPostClasses = [
83+
".post_type_replied"
84+
];
7185

7286
const containClass = replyPostClasses.some((element) => {
73-
return post.classList.contains(element);
87+
return !!post.querySelector(element);
7488
});
7589

7690
return containClass;
@@ -143,9 +157,15 @@ export abstract class Notifications {
143157
* @param node The post div.
144158
*/
145159
protected static getPostInfo(node: HTMLElement): PostInfo {
146-
const messageElement = node.querySelector<HTMLElement>(".post-message");
160+
const messageElement = node.querySelector<HTMLElement>(".post__message");
147161
const messageText = messageElement ? messageElement.innerText : "Не удалось получить сообщение поста.";
148162

163+
if (!node.id) {
164+
// in new layout a new posts is wrapped in empty div.
165+
// so, we are searching for actual post.
166+
node = node.querySelector(`[id*=post]`);
167+
}
168+
149169
const href = node.id ? `${window.location.pathname}#${node.id}` : window.location.pathname;
150170

151171
return {message: messageText, href: href};

src/interaction/js/content/page-elements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ abstract class Custom {
405405
try {
406406
figures = API.getElements<Elements.Element>({
407407
dcmnt: element,
408-
selector: "figure.image",
408+
selector: "figure.post__image",
409409
errorMessage: "Could not find a figure elements."
410410
});
411411
} catch (error) {

src/interaction/js/content/screenshot.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ interface ElementsInstances {
277277
postPanelInstance: HTMLElement;
278278
checkboxInstance: HTMLElement;
279279
spoilerInstance: HTMLElement;
280+
adminbarInstance: HTMLElement;
280281
customDownloadButton: HTMLDivElement;
281282
customInfoButton: HTMLDivElement;
282283
}
@@ -297,6 +298,7 @@ interface DefaultOptions {
297298
postPanelDisplay: string;
298299
checkboxDisplay: string;
299300
spoilerColor: string;
301+
adminbarDisplay: string;
300302
customDownloadButtonDisplay: string;
301303
customInfoButtonDisplay: string;
302304
}
@@ -311,9 +313,10 @@ export abstract class PageOptions {
311313
boardStatsBox: "#boardstats-box",
312314
favoritesBox: "#favorites-box",
313315
autorefresh: "#autorefresh-checkbox-bot",
314-
postPanel: ".postpanel",
315-
checkbox: `.post-details > input[type="checkbox"]`,
316+
postPanel: ".post__details .post__detailpart:last-of-type",
317+
checkbox: `.post__details > input[type="checkbox"]`,
316318
spoiler: ".spoiler",
319+
adminbar: ".adminbar",
317320
customDownloadButton: `.${PageElements.customClasses.downloadButton}`,
318321
customInfoButton: ".custom-2ch-helper-info-button"
319322
};
@@ -334,7 +337,8 @@ export abstract class PageOptions {
334337
customInfoButton: this.getElement(this.selectors.customInfoButton) as HTMLDivElement,
335338
postPanelInstance: this.getElement(this.selectors.postPanel),
336339
checkboxInstance: this.getElement(this.selectors.checkbox),
337-
spoilerInstance: this.getElement(this.selectors.spoiler)
340+
spoilerInstance: this.getElement(this.selectors.spoiler),
341+
adminbarInstance: this.getElement(this.selectors.adminbar)
338342
};
339343
}
340344

@@ -360,6 +364,7 @@ export abstract class PageOptions {
360364
postPanelDisplay: this._elements.postPanelInstance ? this._elements.postPanelInstance.style.display : undefined,
361365
checkboxDisplay: this._elements.checkboxInstance ? this._elements.checkboxInstance.style.display : undefined,
362366
spoilerColor: this._elements.spoilerInstance ? this._elements.spoilerInstance.style.color : undefined,
367+
adminbarDisplay: this._elements.adminbarInstance ? this._elements.adminbarInstance.style.display : undefined,
363368
customDownloadButtonDisplay: this._elements.customDownloadButton ? this._elements.customDownloadButton.style.display : undefined,
364369
customInfoButtonDisplay: this._elements.customInfoButton ? this._elements.customInfoButton.style.display : undefined
365370
};
@@ -402,6 +407,11 @@ export abstract class PageOptions {
402407
element.style.color = "inherit";
403408
});
404409

410+
const adminbars = document.querySelectorAll<HTMLElement>(this.selectors.adminbar);
411+
adminbars.forEach((element) => {
412+
element.style.display = "none";
413+
});
414+
405415
const customDownloadButtons = document.querySelectorAll<HTMLElement>(this.selectors.customDownloadButton);
406416
customDownloadButtons.forEach((element) => {
407417
element.style.display = "none";
@@ -443,6 +453,11 @@ export abstract class PageOptions {
443453
element.style.color = this._defaults.spoilerColor;
444454
});
445455

456+
const adminbars = document.querySelectorAll<HTMLElement>(this.selectors.adminbar);
457+
adminbars.forEach((element) => {
458+
element.style.display = this._defaults.adminbarDisplay;
459+
});
460+
446461
const customDownloadButtons = document.querySelectorAll<HTMLElement>(this.selectors.customDownloadButton);
447462
customDownloadButtons.forEach((element) => {
448463
element.style.display = this._defaults.customDownloadButtonDisplay;

src/interaction/js/content/title-generation.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export abstract class TitleGeneration {
264264
*/
265265
public static generateTitle(thread: HTMLElement): void {
266266
// if already exists.
267-
if (thread.querySelector(".post-title")) {
267+
if (thread.querySelector(".post__title")) {
268268
return;
269269
}
270270

@@ -278,7 +278,7 @@ export abstract class TitleGeneration {
278278
}
279279

280280
const span = document.createElement("span");
281-
span.classList.add("post-title");
281+
span.classList.add("post__title");
282282
span.innerText = title;
283283

284284
const beforeElement = this.getBeforeInsertElement(thread);
@@ -288,7 +288,7 @@ export abstract class TitleGeneration {
288288
} else {
289289
const postDetails = API.getElement<HTMLElement>({
290290
dcmnt: thread,
291-
selector: ".post-details",
291+
selector: ".post__details",
292292
errorMessage: "Could not find a post details elements."
293293
});
294294
postDetails.appendChild(span);
@@ -306,7 +306,7 @@ export abstract class TitleGeneration {
306306
protected static createTitle(thread: HTMLElement): string {
307307
const message = API.getElement<HTMLElement>({
308308
dcmnt: thread,
309-
selector: ".post-message",
309+
selector: ".post__message",
310310
errorMessage: "Could not find a post message."
311311
});
312312

@@ -359,25 +359,25 @@ export abstract class TitleGeneration {
359359
* @returns Returns `undefined` if cannot find.
360360
*/
361361
protected static getBeforeInsertElement(thread: HTMLElement): HTMLElement {
362-
const details = thread.querySelector("div.post-details");
362+
const details = thread.querySelector("div.post__details");
363363

364364
if (!details) return undefined;
365365

366366
let element = undefined;
367367

368-
element = details.querySelector(".ananimas");
368+
element = details.querySelector(".post__anon");
369369
if (element) return element;
370370

371-
element = details.querySelector(".post-email");
371+
element = details.querySelector(".post__email");
372372
if (element) return element;
373373

374-
element = details.querySelector(".posttime");
374+
element = details.querySelector(".post__time");
375375
if (element) return element;
376376

377-
element = details.querySelector(".reflink");
377+
element = details.querySelector(".post__reflink");
378378
if (element) return element;
379379

380-
element = details.querySelector(".postpanel");
380+
element = details.querySelector(".post__detailpart");
381381
if (element) return element;
382382

383383
element = details.querySelector(".desktop");

src/interface/html/common/html5.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
block vars
2-
- var version = "1.2.0";
3-
- var year = "2018";
2+
- var version = "1.2.1";
3+
- var year = "2019";
44
- var title = "2ch-helper";
55

66

0 commit comments

Comments
 (0)