Fixed image loaders

This commit is contained in:
Mr. Stallion 2020-04-04 13:38:00 -05:00
parent c40b507a67
commit cfc9f89aa1
10 changed files with 214 additions and 163 deletions

View File

@ -160,15 +160,26 @@
const e = event as DidFailLoadEvent;
if (e.errorCode < 0) {
// console.error('DID FAIL LOAD', event);
// const url = this.getUrl() || '';
//
// const qjs = this.jsMutator.getMutatorJsForSite(url, 'update-target-url')
// || this.jsMutator.getMutatorJsForSite(url, 'dom-ready');
//
// // tslint:disable-next-line
// this.executeJavaScript(qjs, 'did-fail-load-but-still-loading', event);
return;
const url = webview.getURL();
if (url.match(/^https?:\/\/(www.)?pornhub.com/)) {
const qjs = this.jsMutator.getMutatorJsForSite(url, 'update-target-url')
|| this.jsMutator.getMutatorJsForSite(url, 'dom-ready');
// tslint:disable-next-line
this.executeJavaScript(qjs, 'did-fail-load-but-still-loading', event);
return;
}
// console.error('DID FAIL LOAD', event);
// const url = this.getUrl() || '';
//
// const qjs = this.jsMutator.getMutatorJsForSite(url, 'update-target-url')
// || this.jsMutator.getMutatorJsForSite(url, 'dom-ready');
//
// // tslint:disable-next-line
// this.executeJavaScript(qjs, 'did-fail-load-but-still-loading', event);
return;
}
// if (e.errorCode < 100) {

View File

@ -1,14 +1,29 @@
// window.onload = () => console.log('window.onload');
// window.onloadstart = () => console.log('window.onloadstart');
// window.onloadend = () => console.log('window.onloadend');
// window.addEventListener('DOMContentLoaded', () => (console.log('window.DOMContentLoaded')));
// setTimeout(() => (console.log('Timeout')), 0); ---- Note that clear() below will break this
(() => {
try {
if (window.location.href.match(/^https?:\/\/(www.)?pornhub.com/)) {
const el = document.createElement('script');
el.type='text/javascript';
el.text="console.log('JQuery Injection'); window.$ = window.jQuery = require('jquery');";
document.appendChild(el);
if (!window.zest) {
window.zest = (q) => (document.querySelectorAll(q));
}
}
} catch (err) {
console.error('PornHub integration', err);
}
})();
(() => {
try {
const clear = () => {
if (window.location.href.match(/^https?:\/\/(www.)?pornhub.com/)) {
if (!window.zest) {
window.zest = (q) => (document.querySelectorAll(q));
}
return;
}
try {
const frameCount = window.frames.length;
@ -36,27 +51,26 @@
console.error('Element remove', e);
}
const intervalCount = setInterval(() => {}, 10000);
// const intervalCount = setInterval(() => {}, 10000);
//
// for (let i = 0; i <= intervalCount; i++) {
// try {
// clearInterval(i);
// } catch (e) {
// console.error('Clear interval', i, e);
// }
// }
//
//
// const timeoutCount = setTimeout(() => {}, 10000);
//
// for (let i = 0; i <= timeoutCount; i++) {
// try {
// clearTimeout(i);
// } catch (e) {
// console.error('Clear timeout', i, e);
// }
// }
for (let i = 0; i <= intervalCount; i++) {
try {
clearInterval(i);
} catch (e) {
console.error('Clear interval', i, e);
}
}
const timeoutCount = setTimeout(() => {}, 10000);
for (let i = 0; i <= timeoutCount; i++) {
try {
clearTimeout(i);
} catch (e) {
console.error('Clear timeout', i, e);
}
}
};
console.log('Document loading', Date.now());

View File

@ -5,7 +5,6 @@ import * as urlHelper from 'url';
import { domain as extractDomain } from '../../bbcode/core';
import { PornhubIntegration } from './integration/pornhub';
export interface PreviewMutator {
match: string | RegExp;
@ -138,12 +137,12 @@ export class ImagePreviewMutator {
this.add('giphy.com', this.getBaseJsMutatorScript(['video', 'a > div > img']));
this.add(/^media[0-9]\.tenor\.com$/, this.getBaseJsMutatorScript(['#view .file video', '#view .file img']));
this.add('tenor.com', this.getBaseJsMutatorScript(['#view video', '#view img']));
this.add('hypnohub.net', this.getBaseJsMutatorScript(['video', '#image', 'img']));
this.add('derpibooru.org', this.getBaseJsMutatorScript(['video', '#image-display', 'img']));
this.add(
'pornhub.com',
PornhubIntegration.preprocess()
+ this.getBaseJsMutatorScript(['#__flistCore', '#player'], true)
+ PornhubIntegration.postprocess()
this.getBaseJsMutatorScript([/*'#__flistCore', '#player', */ '#photoImageSection img', 'video', 'img', '#player'], false)
);
this.add(
@ -165,6 +164,7 @@ export class ImagePreviewMutator {
`
);
this.add(
'imgur.com',
`
@ -209,11 +209,23 @@ export class ImagePreviewMutator {
}
getBaseJsMutatorScript(elSelector: string[], skipElementRemove: boolean = false, safeTags: string[] = []): string {
return `const { ipcRenderer } = require('electron');
return `
const ipcRenderer = (typeof require !== 'undefined')
? require('electron').ipcRenderer
: { sendToHost: (...args) => (console.log('ipc.sendToHost', ...args)) };
const body = document.querySelector('body');
const html = document.querySelector('html');
const selectors = ${JSON.stringify(elSelector)};
for (const el of document.querySelectorAll('header, .header')) {
try {
el.remove();
} catch (err) {
console.error('Header removal error', err);
}
}
// writing this out because sometimes .map and .reduce are overridden
let selected = [];
@ -224,7 +236,7 @@ export class ImagePreviewMutator {
${this.debug ? `console.log('Selector', '${elSelector.toString()}'); console.log('Selected', selected);` : ''}
const img = selected.shift();
const img = selected.filter(el => (el !== body)).shift();
${this.debug ? `console.log('Img', img);` : ''}
@ -290,7 +302,7 @@ export class ImagePreviewMutator {
img.style = 'object-position: top left !important; object-fit: contain !important;'
+ 'width: 100% !important; height: 100% !important; opacity: 1 !important;'
+ 'margin: 0 !imporant; border: 0 !important; padding: 0 !important;'
+ 'margin: 0 !important; border: 0 !important; padding: 0 !important;'
+ 'min-width: initial !important; min-height: initial !important; max-width: initial !important; max-height: initial !important;'
+ 'display: block !important; visibility: visible !important;';
@ -307,6 +319,29 @@ export class ImagePreviewMutator {
+ 'min-width: initial !important; min-height: initial !important; max-width: initial !important; max-height: initial !important;'
+ 'display: block !important; visibility: visible !important';
const extraStyle = document.createElement('style');
extraStyle.textContent = \`
#flistWrapper img, #flistWrapper video {
object-position: top left !important;
object-fit: contain !important;
width: 100% !important;
height: 100% !important;
opacity: 1 !important;
margin: 0 !important;
border: 0 !important;
padding: 0 !important;
min-width: initial !important;
min-height: initial !important;
max-width: initial !important;
max-height: initial !important;
display: block !important;
visibility: visible !important;
}
\`;
el.append(extraStyle);
${this.debug ? "console.log('Wrapper', el);" : ''}
if ((!img.src) && (img.tagName) && (img.tagName.toUpperCase() === 'VIDEO')) {

View File

@ -37,6 +37,15 @@ export class ImageUrlMutator {
}
);
this.add(
/^https?:\/\/(www.)?pornhub.com\/gif\/([a-z0-9A-Z]+)/,
async(_url: string, match: RegExpMatchArray): Promise<string> => {
const gifId = match[2];
return `https://pornhub.com/embedgif/${gifId}`;
}
);
this.add(
/^https?:\/\/(www.)?gfycat.com\/([a-z0-9A-Z\-]+)\/?$/,
async(_url: string, match: RegExpMatchArray): Promise<string> => {
@ -46,6 +55,32 @@ export class ImageUrlMutator {
}
);
this.add(
/^https?:\/\/e621.net\/(posts|post\/show)\/([0-9]+)/,
async(url: string, match: RegExpMatchArray): Promise<string> => {
const galleryId = match[2];
try {
const result = await Axios.get(
`https://e621.net/posts/${galleryId}.json`,
{
// headers: {
// 'User-Agent': 'F-List-Rising-Client/1.0'
// }
}
);
const imageUrl = _.get(result, 'data.post.file.url') as string;
return imageUrl || url;
} catch(err) {
console.error('E621 API Failure', url, err);
return url;
}
}
);
this.add(
/^https?:\/\/imgur.com\/gallery\/([a-zA-Z0-9]+)/,
async(url: string, match: RegExpMatchArray): Promise<string> => {

View File

@ -3,75 +3,11 @@
export class PornhubIntegration {
static preprocess(): string {
return `
const phCreateElement = (html) => {
const range = document.createRange();
range.selectNode(document.body);
const el = range.createContextualFragment(html);
document.body.appendChild(el);
}
const phGifImg = document.querySelector('[data-mp4],[data-webm],[data-gif]');
if (phGifImg) {
const phGifVideoUrl = phGifImg.dataset.mp4 || phGifImg.dataset.webm;
if (phGifVideoUrl) {
phCreateElement(\`<video src="\${phGifVideoUrl}" id="__flistCore"></video>\`);
}
const phGifUrl = phGifImg.dataset.gif;
if (phGifUrl) {
phCreateElement(\`<img src="\${phGifUrl}" id="__flistCore" />\`);
}
}
`;
return ``;
}
static postprocess(): string {
return `
document.addEventListener('load', (event) => {
const phVideo = document.querySelector('video');
console.log('LOAD LOAD', phVideo);
if (
(phVideo) && (phVideo.play)
&& ((!phVideo.ended) && (!(phVideo.currentTime > 0)))
)
{
console.log('LOAD PLAYPLAY');
phVideo.muted = true;
phVideo.loop = true;
phVideo.play();
}
});
try {
const phVideo = document.querySelector('video');
console.log('TRY TRY', phVideo);
if (
(phVideo) && (phVideo.play)
&& ((!phVideo.ended) && (!(phVideo.currentTime > 0)))
)
{
console.log('TRY PLAYPLAY');
phVideo.muted = true;
phVideo.loop = true;
phVideo.play();
}
} catch (err) {
console.error('Failed phVideo.play()', err);
}
`;
return ``;
}
}

View File

@ -1,33 +1,17 @@
[url=https://giphy.com/gifs/arianagrande-ariana-grande-thank-u-next-you-uldtLAK6tSOKP5PWw3]Test[/url]
[url=https://static1.e621.net/data/6d/bf/6dbf0c369793dbb5a53d9814c17861eb.webm]E621 static video[/url]
[url=https://media1.tenor.com/images/097ee180965dd336f470b77d064f198f/tenor.gif?itemid=13664909]Test[/url]
[url=https://static1.e621.net/data/6d/bf/6dbf0c369793dbb5a53d9814c17861eb.webm]E621 static image[/url]
[url=https://tenor.com/view/thank-unext-ariana-grande-thank-you-next-wink-winking-gif-13664909]Test[/url]
[url=https://static1.e621.net/data/3f/ac/3facfd9fc11a49250c404e9ac9efcbfc.gif]E621 static gif[/url]
[url=https://www.sex.com/pin/58497794/]Test[/url]
[url=https://e621.net/post/show/1672753/2018-anthro-antlers-balls-bed-big_penis-black_hair]E621 website post show[/url]
[url=https://cdn.sex.com/images/pinporn/2020/03/03/22687557.gif?width=620]Test[/url]
[url=https://e621.net/posts/2197827]E621 website video[/url]
[url=http://gfycatporn.com/deepthroat.php]Test[/url]
[url=https://e621.net/posts/2200288]E621 website gif[/url]
[url=https://imgur.com/LmEyXEM]Test[/url]
[url=https://static1.e621.net/data/6d/bf/6dbf0c369793dbb5a53d9814c17861eb.webm]Test[/url]
[url=https://www.youtube.com/watch?v=_52zdiltkRM]Test[/url]
[url=https://e621.net/post/show/1672753/2018-anthro-antlers-balls-bed-big_penis-black_hair]Test[/url]
[url=https://rule34.xxx/index.php?page=post&s=view&id=3213191]Test[/url]
[url=https://chan.sankakucomplex.com/post/show/6163997]Test[/url]
[url=https://chan.sankakucomplex.com/post/show/5774884]Test[/url]
[url=https://www.sex.com/pin/38152484-she-likes-it-rough/]Test[/url]
[url=https://www.sex.com/pin/57537179-cock-slapping-hungry-tongue/]Test[/url]
[url=https://imgur.com/LmEyXEM]Imgur[/url]
[url=https://imgur.com/gallery/ILsb94I]Imgur gallery[/url]
@ -37,22 +21,49 @@
[url=http://i.imgur.com/txEREOg.gifv]Imgur video[/url]
[url=https://www.punishbang.com/videos/1898/tied-redhead-is-on-her-knees-and-can/]Test[/url]
[url=https://www.pornhub.com/view_video.php?viewkey=ph5b2c03dc1e23b]Pornhub video[/url]
[url=https://www.pornhub.com/view_video.php?viewkey=ph5b2c03dc1e23b]Test[/url]
[url=https://www.pornhub.com/gif/28316052]Pornhub gif[/url]
[url=https://www.pornhub.com/gif/28316052]Test[/url]
[url=https://www.pornhub.com/photo/524286042]Pornhub photo[/url]
[url=https://vimeo.com/265884960]Test[/url]
[url=https://www.pornhub.com/photo/402223321]Pornhub photo gif[/url]
[url=https://gelbooru.com/index.php?page=post&s=view&id=5210847&tags=tits]Test[/url]
[url=https://chan.sankakucomplex.com/post/show/6163997]Test[/url]
[url=https://chan.sankakucomplex.com/post/show/5774884]Test[/url]
[url=https://danbooru.donmai.us/posts/3841490]Test[/url]
[url=https://danbooru.donmai.us/posts/3709493]Test[/url]
[url=https://giphy.com/gifs/arianagrande-ariana-grande-thank-u-next-you-uldtLAK6tSOKP5PWw3]Test[/url]
[url=https://media1.tenor.com/images/097ee180965dd336f470b77d064f198f/tenor.gif?itemid=13664909]Test[/url]
[url=https://tenor.com/view/thank-unext-ariana-grande-thank-you-next-wink-winking-gif-13664909]Test[/url]
[url=https://www.sex.com/pin/58497794/]Test[/url]
[url=https://www.sex.com/pin/38152484-she-likes-it-rough/]Test[/url]
[url=https://www.sex.com/pin/57537179-cock-slapping-hungry-tongue/]Test[/url]
[url=http://gfycatporn.com/deepthroat.php]Test[/url]
[url=https://www.youtube.com/watch?v=_52zdiltkRM]Test[/url]
[url=https://rule34.xxx/index.php?page=post&s=view&id=3213191]Test[/url]
[url=https://gelbooru.com/index.php?page=post&s=view&id=5210847&tags=tits]Test[/url]
[url=https://hypnohub.net/post/show/93283/3d-auxtasy-aware-brain_drain-d-va-dark_skin-female]Test[/url]
[url=https://www.derpibooru.org/images/2234687?q=video]Derpibooru video[/url]
[url=https://derpibooru.org/images/2313949]Derpibooru regular[/url]
[url=https://www.derpibooru.org/images/2313962]Derpibooru suggestive[/url]
Broken
@ -75,6 +86,8 @@ http://gfycatporn.com/deepthroat.php
Derpibooru
Pornhub GIFS
https://multporn.net/authors_comics/sefeiren
https://hypnohub.net/post/show/79257/arms_above_head-bat_wings-black_hair-bondage-botto
https://ibb.co/BqJswjf

View File

@ -205,29 +205,29 @@ function createWindow(): Electron.BrowserWindow | undefined {
// // console.log('Got this far!!!!');
//
// blocker.on('request-blocked', (request: Request) => {
// console.log('blocked', request.url);
// });
//
// blocker.on('request-redirected', (request: Request) => {
// console.log('redirected', request.url);
// });
//
// blocker.on('request-whitelisted', (request: Request) => {
// console.log('whitelisted', request.url);
// });
//
// blocker.on('csp-injected', (request: Request) => {
// console.log('csp', request.url);
// });
//
// blocker.on('script-injected', (script: string, url: string) => {
// console.log('script', script.length, url);
// });
//
// blocker.on('style-injected', (style: string, url: string) => {
// console.log('style', style.length, url);
// });
blocker.on('request-blocked', (request: Request) => {
console.log('blocked', request.url);
});
blocker.on('request-redirected', (request: Request) => {
console.log('redirected', request.url);
});
blocker.on('request-whitelisted', (request: Request) => {
console.log('whitelisted', request.url);
});
blocker.on('csp-injected', (request: Request) => {
console.log('csp', request.url);
});
blocker.on('script-injected', (script: string, url: string) => {
console.log('script', script.length, url);
});
blocker.on('style-injected', (style: string, url: string) => {
console.log('style', style.length, url);
});
}
);

View File

@ -44,6 +44,7 @@
},
"dependencies": {
"@cliqz/adblocker-electron": "^1.13.0",
"jquery": "^3.4.1",
"keytar": "^4.10.0",
"node-fetch": "^2.6.0"
},

View File

@ -83,6 +83,7 @@ This repository contains a heavily customized version of the mainline F-Chat 3.0
1. 'Underage' kink is considered to apply to characters aged 16 or above; 'ageplay' kink is considered to apply to characters aged 16 or below.
1. 'Older characters' and 'younger characters' kink preferences are interpreted as age difference of 5+ years.
1. Comparison results will get faster over time, as more and more character data is cached.
1. Loading animation
## Todo / Ideas

View File

@ -3521,6 +3521,11 @@ isstream@~0.1.2:
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=
jquery@^3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2"
integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==
js-base64@^2.1.8:
version "2.5.2"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.2.tgz#313b6274dda718f714d00b3330bbae6e38e90209"