Undefined error in plupload dispatchEvent on Mac Safari - javascript

I am experiencing weird errors on Mac Safari with plupload.js. The method dispatchEvent has this line:
evt.type = eventType;
It sometimes throws this error:
TypeError: undefined is not an object (evaluating 'evt.type = eventType')" userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12
The evt object is declared at the top of the method:
var evt = {};
It is not re-declared anywhere below. I am not able to reproduce this error locally, I have it in my logs from other users. How can this happen? Might it be a problem with JS implementation on Mac Safari so that some other thread is erasing the evt object?
EDIT: The problematic line of code is here https://github.com/moxiecode/plupload/blob/3.x/js/plupload.js#L2200

Related

Netflix player seek() inconsistent behaviour

I am using the Netflix videoPlayer API to control Netflix in a Chrome extension, and I am getting different behavior with the seek() function between machines. Machine 1 can control seek() with millisecond precision, while Machine 2 seems to only be able to seek on pre-defined boudaries. All are running Ubuntu 18LTS with Chrome 100.0.4896.75 (Official Build) (64-bit).
Machine 1 log:
Version: 6.0034.519.911
Esn: NFCDCH-LX-HTF16YUDF2YGKFVCYRJ3A9GF9H7RVN
JsSid: 164987005943084260, Epoch: 1649870627, Start: 1649870059, TimeZone: 240
Href: https://www.netflix.com/watch/80133015?trackId=14277281&tctx=-97%2C-97%2C%2C%2C%2C%2C%2C
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36
--------------------------------------------------------------------------------
561.357|0|I|Playback| PresentingState changed, From: 3, To: 1, MediaTime: 60.001, AudioBufferLength: 238211, VideoBufferLength: 239548
561.359|0|I|MediaPresenterASE| Seeking, Requested: 120.000, Actual: 120.001, Cause: 1, Skip: true
561.567|0|I|Playback| PresentingState changed, From: 1, To: 3, MediaTime: 120.001, AudioBufferLength: 178211, VideoBufferLength: 179548
Machine 2 log:
Version: 6.0034.519.911
Esn: NFCDCH-LX-J5EWUE0WEKL01A5EUP9QQVGXQWR07G
JsSid: 164986955062224580, Epoch: 1649870664, Start: 1649869550, TimeZone: 0
Href: https://www.netflix.com/watch/80133015?trackId=14170286&tctx=2%2C0%2C7363e895-693b-49fb-ab7e-652cda8c88bc-402829570%2C6d31be72-de22-4cad-9be0-711eb9a14bf9_33273644X3XX1649867233503%2C6d31be72-de22-4cad-9be0-711eb9a14bf9_ROOT%2C%2C%2C
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36
--------------------------------------------------------------------------------
1106.457|0|I|Playback| PresentingState changed, From: 3, To: 1, MediaTime: 59.241, AudioBufferLength: 214950, VideoBufferLength: 229505
1106.459|0|I|MediaPresenterASE| Seeking, Requested: 120.000, Actual: 117.743, Cause: 1, Skip: true
1106.494|0|W|DFF| Restricting resolution due to high number of dropped frames, MaxHeight: 720
1107.138|0|I|Playback| PresentingState changed, From: 1, To: 3, MediaTime: 117.743, AudioBufferLength: 204491, VideoBufferLength: 190815
Both request a seek(120000), and Machine 1 seeks to 120.001, while Machine 2 seeks to 117.743 (as do any requests for 118 and 119). It is unclear if this is related to the "restricting resolution" message on Machine 2. I would like both machines to be able to seek() with millisecond precision.

Python Discord Bot and JS custom google browser

i am new here and i wanted to create a custom Discord Bot. Starting with python, i was trying to implement a youtube searching feature to it, but i got locked away because of some user agent problem that looks overcomplicated for me, so i went to Developers.Google and i proceeded to create myself a custom search engine supposed to work with Youtube since i already had the API of it, but i realised that the code for it was in JS, thus making me ask the question : is it possible to make this custom search engine work with my Python Bot ?
here is my current code for it :
import urllib.parse, urllib.request, re
import aiohttp
import asyncio
from googleapiclient.discovery import build
def get_service():
return build("youtube", "v3", developerKey="edmond-dantefesses")
def search(term, channel):
service = get_service()
resp = service.search().list(
part="id",
q=term,
# safeSearch="none" if channel.is_nsfw() else "moderate",
videoDimension="2d",
).execute()
return resp["items"][0]["id"]["videoId"]
BASE = "https://youtube.com/results"
#bot.command()
async def YT(ctx, *, search):
p = {"search_query": search}
# Spoof a user agent header or the request will immediately fail
h = {"User-Agent": "Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"}
async with aiohttp.ClientSession() as bot:
async with bot.get(BASE, params=p, headers=h) as resp:
dom = await resp.text()
# open("debug.html", "w").write(dom)
found = re.findall(r'href"\/watch\?v=([a-zA-Z0-9_-]{11})', dom)
return f"https://youtu.be/{found[0]}"
i understand if my question sounds stupid or surreal and i thank you very much for your patience, have a good day :)

phantomjs and simple examples gives TypeError: Attempting to change the setter of an unconfigurable property

I'm working my way through the phantomjs examples but TypeError: Attempting to change the setter of an unconfigurable property. errors keep popping up. I wanted to pipe returned values to files but they are full of these error messages even with the simple examples see below.
var webPage = require('webpage');
var page = webPage.create();
page.settings.userAgent = 'Mozilla/5.0 (Linux; Android 9; SM-G960F Build/PPR1.180610.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.157 Mobile Safari/537.36';
page.open('http://m.bing.com', function(status) {
var title = page.evaluate(function() {
return document.title;
});
console.log(title);
phantom.exit();
});
Produces:
Bing
TypeError: Attempting to change the setter of an unconfigurable property.
TypeError: Attempting to change the setter of an unconfigurable property.
It should send back just Bing any workarounds?
I'm using PhantomJS 2.1.1 on Ubuntu 18.04 64bit.

How to catch google chrome audit lighthouse

How can I catch in Javascript a user running an Audit from Lighthouse in my website?
I'd like to see if there is a possibility, out of curiosity.
Edit:
Based on #DBS answer, I'd like to see that If I can catch it during the process
<script>
if (navigator.userAgent.indexOf("Chrome-Lighthouse") > -1) {
document.body.innerHTML = "Lighthouse!";
} else {
document.body.innerHTML = "No lighthouse :("
}
</script>
If by "catch", you simply mean detect it. The Lighthouse process includes a custom user agent.
Searching the user agent for the string Chrome-Lighthouse
e.g.
if (navigator.userAgent.indexOf("Chrome-Lighthouse") > -1) {
console.log("Lighthouse!");
} else {
console.log("No lighthouse :(")
}
I don't believe it's possible to "catch" in the debugging sense of interacting with the process.
You might be able to catch it from the User agent.
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse
From Source Code

Karma/Jasmine Tests and dropbox authentication in javascript

I'm attempting to create some tests using Karma and Jasmine for a javascript application that uses the Dropbox Datastore api.
Here is a simplified test using the introductory Dropbox code from https://www.dropbox.com/developers/datastore/tutorial/js
I've manually authorized the application with Dropbox in the browser before running the test, but when I run the test, it says the client is not authenticated and no error occurs. Is there something extra that needs to be done for it to authenticate when running the tests?
'use strict';
describe('dropbox', function () {
var client = null;
beforeEach(function() {
client = new Dropbox.Client({key: '46tjf8x15q98xic'});
// Try to finish OAuth authorization.
client.authenticate({interactive: false}, function (error) {
if (error) {
alert('Authentication error: ' + error);
}
});
});
it('client is not null', function() {
expect( client ).not.toBeNull();
});
it('authenticated is true', function() {
expect( client.isAuthenticated() ).toEqual( true );
});
});
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.10.9 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 33.0.1750 (Mac OS X 10.9.2)]: Connected on socket BKoS8rqqeeL7fg3cHEQl
Chrome 33.0.1750 (Mac OS X 10.9.2) dropbox authenticated is true FAILED
Expected false to equal true.
Error: Expected false to equal true.
at null.<anonymous> (/Users/davidsmith/Sites/myapp/test/spec/dropbox.js:23:38)
Chrome 33.0.1750 (Mac OS X 10.9.2): Executed 2 of 2 (1 FAILED) (0.301 secs / 0.009 secs)
Warning: Task "karma:unit" failed. Use --force to continue.
Aborted due to warnings.
So, to be able to run the tests, I looked at the local storage for my browser and copied my app's dropbox key/value pair.
In my test script, I added that key/value pair with
var value = '{"key":"46tjf8x15q98xic","token":"srMz5w4ReBsAAAAAAAAAAWfQfibrbJfeI7LVKsbMvxRfX1pdpS6SOKqvN6DcgK1B","uid":"1407454"}';
localStorage.setItem('dropbox-auth:default:cHKvNCKVzU7Jmnyaj1InU8TBCOc', value );
Another related problem (not shown above) is that openDefaultDatastore is asyncronous so in my test script I added some code to wait until openDefaultDatastore finishes before running my tests.

Categories

Resources