Merge pull request #18 from MillenniumEarl/deepsource-transform-0c1c8af6
Format code with prettierpull/19/head
commit
b5444f7057
|
@ -1,29 +1,31 @@
|
||||||
module.exports = Object.freeze({
|
module.exports = Object.freeze({
|
||||||
AVATAR_INFO: 'span.avatar',
|
AVATAR_INFO: "span.avatar",
|
||||||
AVATAR_PIC: 'a[href="/account/"] > span.avatar > img[class^="avatar"]',
|
AVATAR_PIC: 'a[href="/account/"] > span.avatar > img[class^="avatar"]',
|
||||||
ENGINE_ID_SELECTOR: 'div[id^="btn-prefix_1_"]>span',
|
ENGINE_ID_SELECTOR: 'div[id^="btn-prefix_1_"]>span',
|
||||||
FILTER_THREADS_BUTTON: 'button[class="button--primary button"]',
|
FILTER_THREADS_BUTTON: 'button[class="button--primary button"]',
|
||||||
GAME_IMAGES: 'img[src^="https://attachments.f95zone.to"]',
|
GAME_IMAGES: 'img[src^="https://attachments.f95zone.to"]',
|
||||||
GAME_TAGS: 'a.tagItem',
|
GAME_TAGS: "a.tagItem",
|
||||||
GAME_TITLE: 'h1.p-title-value',
|
GAME_TITLE: "h1.p-title-value",
|
||||||
GAME_TITLE_PREFIXES: 'h1.p-title-value > a.labelLink > span[dir="auto"]',
|
GAME_TITLE_PREFIXES: 'h1.p-title-value > a.labelLink > span[dir="auto"]',
|
||||||
LOGIN_BUTTON: 'button.button--icon--login',
|
LOGIN_BUTTON: "button.button--icon--login",
|
||||||
LOGIN_MESSAGE_ERROR: 'div.blockMessage.blockMessage--error.blockMessage--iconic',
|
LOGIN_MESSAGE_ERROR:
|
||||||
|
"div.blockMessage.blockMessage--error.blockMessage--iconic",
|
||||||
ONLY_GAMES_THREAD_OPTION: 'select[name="nodes[]"] > option[value="2"]',
|
ONLY_GAMES_THREAD_OPTION: 'select[name="nodes[]"] > option[value="2"]',
|
||||||
PASSWORD_INPUT: 'input[name="password"]',
|
PASSWORD_INPUT: 'input[name="password"]',
|
||||||
SEARCH_BUTTON: 'form.block > * button.button--icon--search',
|
SEARCH_BUTTON: "form.block > * button.button--icon--search",
|
||||||
SEARCH_FORM_TEXTBOX: 'input[name="keywords"]',
|
SEARCH_FORM_TEXTBOX: 'input[name="keywords"]',
|
||||||
STATUS_ID_SELECTOR: 'div[id^="btn-prefix_4_"]>span',
|
STATUS_ID_SELECTOR: 'div[id^="btn-prefix_4_"]>span',
|
||||||
THREAD_POSTS: 'article.message-body:first-child > div.bbWrapper:first-of-type',
|
THREAD_POSTS:
|
||||||
THREAD_TITLE: 'h3.contentRow-title',
|
"article.message-body:first-child > div.bbWrapper:first-of-type",
|
||||||
|
THREAD_TITLE: "h3.contentRow-title",
|
||||||
TITLE_ONLY_CHECKBOX: 'form.block > * input[name="c[title_only]"]',
|
TITLE_ONLY_CHECKBOX: 'form.block > * input[name="c[title_only]"]',
|
||||||
UNREAD_THREAD_CHECKBOX: 'input[type="checkbox"][name="unread"]',
|
UNREAD_THREAD_CHECKBOX: 'input[type="checkbox"][name="unread"]',
|
||||||
USERNAME_ELEMENT: 'a[href="/account/"] > span.p-navgroup-linkText',
|
USERNAME_ELEMENT: 'a[href="/account/"] > span.p-navgroup-linkText',
|
||||||
USERNAME_INPUT: 'input[name="login"]',
|
USERNAME_INPUT: 'input[name="login"]',
|
||||||
WATCHED_THREAD_FILTER_POPUP_BUTTON: 'a.filterBar-menuTrigger',
|
WATCHED_THREAD_FILTER_POPUP_BUTTON: "a.filterBar-menuTrigger",
|
||||||
WATCHED_THREAD_NEXT_PAGE: 'a.pageNav-jump--next',
|
WATCHED_THREAD_NEXT_PAGE: "a.pageNav-jump--next",
|
||||||
WATCHED_THREAD_URLS: 'a[href^="/threads/"][data-tp-primary]',
|
WATCHED_THREAD_URLS: 'a[href^="/threads/"][data-tp-primary]',
|
||||||
DOWNLOAD_LINKS_CONTAINER: 'span[style="font-size: 18px"]',
|
DOWNLOAD_LINKS_CONTAINER: 'span[style="font-size: 18px"]',
|
||||||
SEARCH_THREADS_RESULTS_BODY: "div.contentRow-main",
|
SEARCH_THREADS_RESULTS_BODY: "div.contentRow-main",
|
||||||
SEARCH_THREADS_MEMBERSHIP: "li > a:not(.username)"
|
SEARCH_THREADS_MEMBERSHIP: "li > a:not(.username)",
|
||||||
});
|
});
|
|
@ -87,8 +87,7 @@ module.exports.getGameVersionFromTitle = async function(browser, info) {
|
||||||
// Get the title
|
// Get the title
|
||||||
let titleHTML = await page.evaluate(
|
let titleHTML = await page.evaluate(
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
(selector) =>
|
(selector) => document.querySelector(selector).innerHTML,
|
||||||
document.querySelector(selector).innerHTML,
|
|
||||||
selectors.GAME_TITLE
|
selectors.GAME_TITLE
|
||||||
);
|
);
|
||||||
let title = HTMLParser.parse(titleHTML).childNodes.pop().rawText;
|
let title = HTMLParser.parse(titleHTML).childNodes.pop().rawText;
|
||||||
|
@ -99,7 +98,7 @@ module.exports.getGameVersionFromTitle = async function(browser, info) {
|
||||||
let version = title.substring(startIndex, endIndex).trim().toUpperCase();
|
let version = title.substring(startIndex, endIndex).trim().toUpperCase();
|
||||||
if (version.startsWith("V")) version = version.replace("V", ""); // Replace only the first occurrence
|
if (version.startsWith("V")) version = version.replace("V", ""); // Replace only the first occurrence
|
||||||
return version;
|
return version;
|
||||||
}
|
};
|
||||||
|
|
||||||
//#region Private methods
|
//#region Private methods
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Public modules from npm
|
// Public modules from npm
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require("puppeteer");
|
||||||
|
|
||||||
// Modules from file
|
// Modules from file
|
||||||
const shared = require("./shared.js");
|
const shared = require("./shared.js");
|
||||||
const constURLs = require("./constants/urls.js");
|
const constURLs = require("./constants/urls.js");
|
||||||
const selectors = require("./constants/css-selectors.js");
|
const selectors = require("./constants/css-selectors.js");
|
||||||
const {
|
const { preparePage } = require("./puppeteer-helper.js");
|
||||||
preparePage,
|
|
||||||
} = require("./puppeteer-helper.js");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
|
@ -53,7 +51,7 @@ module.exports.getSearchGameResults = async function(browser, gamename) {
|
||||||
await page.close(); // Close the page
|
await page.close(); // Close the page
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
};
|
||||||
|
|
||||||
//#region Private methods
|
//#region Private methods
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +89,7 @@ async function getMembershipForum(page, handle) {
|
||||||
|
|
||||||
let link = await page.evaluate(
|
let link = await page.evaluate(
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
(e) => e.getAttribute('href'),
|
(e) => e.getAttribute("href"),
|
||||||
handle
|
handle
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
// Public modules from npm
|
// Public modules from npm
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require("puppeteer");
|
||||||
|
|
||||||
// Modules from file
|
// Modules from file
|
||||||
const shared = require('./shared.js');
|
const shared = require("./shared.js");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
|
@ -19,7 +19,7 @@ module.exports.prepareBrowser = async function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return browser;
|
return browser;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
|
@ -34,18 +34,19 @@ module.exports.preparePage = async function(browser) {
|
||||||
|
|
||||||
// Block image download
|
// Block image download
|
||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
page.on('request', (request) => {
|
page.on("request", (request) => {
|
||||||
if (request.resourceType() === 'image') request.abort();
|
if (request.resourceType() === "image") request.abort();
|
||||||
else if(request.resourceType == 'font') request.abort();
|
else if (request.resourceType == "font") request.abort();
|
||||||
// else if (request.resourceType() == 'stylesheet') request.abort();
|
// else if (request.resourceType() == 'stylesheet') request.abort();
|
||||||
// else if(request.resourceType == 'media') request.abort();
|
// else if(request.resourceType == 'media') request.abort();
|
||||||
else request.continue();
|
else request.continue();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set custom user-agent
|
// Set custom user-agent
|
||||||
let userAgent = 'Mozilla/5.0 (X11; Linux x86_64)' +
|
let userAgent =
|
||||||
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36';
|
"Mozilla/5.0 (X11; Linux x86_64)" +
|
||||||
|
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36";
|
||||||
await page.setUserAgent(userAgent);
|
await page.setUserAgent(userAgent);
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
};
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
const F95API = require("../app/index");
|
const F95API = require("../app/index");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const sleep = require('sleep');
|
const sleep = require("sleep");
|
||||||
const dotenv = require('dotenv');
|
const dotenv = require("dotenv");
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const COOKIES_SAVE_PATH = "./f95cache/cookies.json";
|
const COOKIES_SAVE_PATH = "./f95cache/cookies.json";
|
||||||
|
@ -28,7 +28,7 @@ describe("Login without cookies", function () {
|
||||||
|
|
||||||
before("Set isolation", function () {
|
before("Set isolation", function () {
|
||||||
F95API.setIsolation(true);
|
F95API.setIsolation(true);
|
||||||
})
|
});
|
||||||
|
|
||||||
beforeEach("Remove all cookies", function () {
|
beforeEach("Remove all cookies", function () {
|
||||||
// Runs before each test in this block
|
// Runs before each test in this block
|
||||||
|
@ -221,7 +221,8 @@ describe("Check game update", function () {
|
||||||
|
|
||||||
// This test depend on the data on F95Zone at
|
// This test depend on the data on F95Zone at
|
||||||
// https://f95zone.to/threads/perverted-education-v0-9701-april-ryan.1854/
|
// https://f95zone.to/threads/perverted-education-v0-9701-april-ryan.1854/
|
||||||
let url = "https://f95zone.to/threads/perverted-education-v0-9701-april-ryan.1854/";
|
let url =
|
||||||
|
"https://f95zone.to/threads/perverted-education-v0-9701-april-ryan.1854/";
|
||||||
const result = await F95API.getGameDataFromURL(url);
|
const result = await F95API.getGameDataFromURL(url);
|
||||||
result.version = "0.9600";
|
result.version = "0.9600";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue