This commit is contained in:
Eduard Urbach 2017-10-01 07:50:53 +02:00
parent e646410fc2
commit c8acdc0d11
3 changed files with 34 additions and 37 deletions

26
scripts/Analytics.ts Normal file
View File

@ -0,0 +1,26 @@
export class Analytics {
push() {
let analytics = {
general: {
timezoneOffset: new Date().getTimezoneOffset()
},
screen: {
width: screen.width,
height: screen.height,
availableWidth: screen.availWidth,
availableHeight: screen.availHeight,
pixelRatio: window.devicePixelRatio
},
system: {
cpuCount: navigator.hardwareConcurrency,
platform: navigator.platform
}
}
fetch("/dark-flame-master", {
method: "POST",
credentials: "same-origin",
body: JSON.stringify(analytics)
})
}
}

View File

@ -7,9 +7,11 @@ import { MutationQueue } from "./MutationQueue"
import { StatusMessage } from "./StatusMessage" import { StatusMessage } from "./StatusMessage"
import { PushManager } from "./PushManager" import { PushManager } from "./PushManager"
import { TouchController } from "./TouchController" import { TouchController } from "./TouchController"
import { Analytics } from "./Analytics"
export class AnimeNotifier { export class AnimeNotifier {
app: Application app: Application
analytics: Analytics
user: HTMLElement user: HTMLElement
title: string title: string
webpEnabled: boolean webpEnabled: boolean
@ -118,6 +120,9 @@ export class AnimeNotifier {
// Push manager // Push manager
this.pushManager = new PushManager() this.pushManager = new PushManager()
// Analytics
this.analytics = new Analytics()
// Sidebar control // Sidebar control
this.sideBar = this.app.find("sidebar") this.sideBar = this.app.find("sidebar")
@ -180,7 +185,9 @@ export class AnimeNotifier {
this.registerServiceWorker() this.registerServiceWorker()
// Analytics // Analytics
this.pushAnalytics() if(this.user) {
this.analytics.push()
}
// Offline message // Offline message
if(navigator.onLine === false) { if(navigator.onLine === false) {
@ -290,35 +297,6 @@ export class AnimeNotifier {
} }
} }
pushAnalytics() {
if(!this.user) {
return
}
let analytics = {
general: {
timezoneOffset: new Date().getTimezoneOffset()
},
screen: {
width: screen.width,
height: screen.height,
availableWidth: screen.availWidth,
availableHeight: screen.availHeight,
pixelRatio: window.devicePixelRatio
},
system: {
cpuCount: navigator.hardwareConcurrency,
platform: navigator.platform
}
}
fetch("/dark-flame-master", {
method: "POST",
credentials: "same-origin",
body: JSON.stringify(analytics)
})
}
setSelectBoxValue() { setSelectBoxValue() {
for(let element of document.getElementsByTagName("select")) { for(let element of document.getElementsByTagName("select")) {
element.value = element.getAttribute("value") element.value = element.getAttribute("value")

View File

@ -68,13 +68,6 @@ export class Diff {
let elemA = a as HTMLElement let elemA = a as HTMLElement
let elemB = b as HTMLElement let elemB = b as HTMLElement
// Skip iframes
// This part needs to be executed AFTER lazy images check
// to allow lazily loaded iframes to update their data src.
if(elemA.tagName === "IFRAME") {
continue
}
let removeAttributes: Attr[] = [] let removeAttributes: Attr[] = []
for(let x = 0; x < elemA.attributes.length; x++) { for(let x = 0; x < elemA.attributes.length; x++) {