I have this JSON response (already parsed as JSON so not need $.parseJSON or so on):
{
"raw": {
"userAgent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36",
"os": {
"windows": true,
"mac": false,
"ios": false,
"android": false,
"linux": false,
"unix": false,
"firefox-os": false,
"chrome-os": false,
"windows-phone": false,
"ps4": false,
"vita": false,
"unknown": false
},
"browser": {
"chrome": true,
"firefox": false,
"safari": true,
"opera": false,
"ie": false,
"ms-edge": false,
"ps4": false,
"vita": false,
"unknown": false
},
"device": {
"android": false,
"ipad": false,
"iphone": false,
"ipod": false,
"blackberry": false,
"firefox-os": false,
"chrome-book": false,
"windows-phone": false,
"ps4": false,
"vita": false,
"unknown": false
},
"os_version": {
"windows-3-11": false,
"windows-95": false,
"windows-me": false,
"windows-98": false,
"windows-ce": false,
"windows-2000": false,
"windows-xp": false,
"windows-server-2003": false,
"windows-vista": false,
"windows-7": false,
"windows-8-1": true,
"windows-8": false,
"windows-10": false,
"windows-phone-7-5": false,
"windows-phone-10": false,
"windows-nt-4-0": true,
"unknown": false
}
},
"os": "windows",
"browser": "chrome",
"device": "unknown",
"os_version": "windows-8-1",
"browser_version": "43.0.2357.81"
}
I need to access browser and browser_version and I am doing as follow:
jsonVar.raw.browser
jsonVar.raw.browser_version
But I got:
{"chrome":true,"firefox":false,"safari":true,"opera":false,"ie":false,"ms-edge":false,"ps4":false,"vita":false,"unknown":false}
How do I access those two keys on the JSON?
use the following.
jsonVar.browser
jsonVar.browser_version
Will return the desired values.
Related
In the beginning luckyOrange is sending some request to the API: https://settings.luckyorange.net to fetch some content.
The actual Request URL for this API, which is being shown in other browsers except brave, in the network tab is:
https://settings.luckyorange.net/?u=http%3A%2F%2Flocalhost%3A5000%2F-84.540584%2C39.136547%2C9%3Fq&s=153484
This API is working on the chrome and microsoft edge but not on brave.
In the Brave Browser's console, I am having this response:
GET https://d10lpsik1i8c69.cloudfront.net/w.js net::ERR_BLOCKED_BY_CLIENT -84.540584,39.136547,9?q:9
I have tried:
Allowing everything in the 'Site Settings' which is in the URL bar.
Debugging my application for any other blockers, none.
Also, When hitting that API directly from another tab, it is giving me the response in all browsers (including brave):
{
"masterID": "181739",
"only_enhanced": false,
"offline_form": false,
"log_console": true,
"idle_timeout_mins": 10,
"hubspot": false,
"ga_events": false,
"adobe_dtm_events": false,
"addons": {
"powered_by": false,
"white_label": false,
"beta": false,
"store_resources": false,
"gcs": true,
"rdc": true
},
"big_dom": true,
"keys": false,
"hash_changes": false,
"anon_ip": false,
"polyfill": false,
"newTracking": false,
"throttled": 0,
"offset_bottom": "0",
"chat_align": "right",
"text_dir": "ltr",
"colors": {
"chat_bg": "#000000",
"chat_title": "#ffffff",
"chat_subtitle": "#999999",
"chat_border": "#ffffff",
"chat_show_blinker": "1",
"is_chat_bg_light": false
},
"words": {
"available_for_chat": "",
"offline_message": "",
"extra_msg": "",
"pre_chat_ask_enabled": false,
"pre1": "Enter Your Name",
"pre2": "Enter Your Email",
"pre3": "",
"pre1_r": false,
"pre2_r": false,
"pre3_r": false,
"pre1_t": "text",
"pre2_t": "email",
"pre3_t": "text",
"btn_yes": "Yes, please.",
"btn_no": "No thanks.",
"btn_stop": "Stop asking me.",
"btn_lbl": "chat",
"enter_placeholder": "Type here and press <enter> to chat.",
"you": "you",
"confirm_close": "Are you sure you want to close this chat session?",
"paging_operator": "One moment, we're paging an agent...",
"composing": "is typing...",
"idle": "is idle.",
"away": "is away from their keyboard.",
"closed": "ended the chat."
},
"bc_events": false,
"never_chat": false,
"scramble": false,
"dis_mo_chat": false,
"do_not_record": false,
"extreme_privacy": false,
"ga_polls": "0",
"ga_chat": "0",
"dom_ready": false,
"ip": "157.39.8.146",
"fc": true,
"site_id": 153484,
"access_token": null,
"polls": [],
"invites": [],
"tags": ["Quest Panel"],
"auto": false,
"now": 1665482096,
"now_ms": 1665482096676,
"t": 75.708150863647,
"ek": "30",
"enable_chat": false
}
If I try to get an JSON response from a backend I wrote I get following response which is completely correct:
{
"status": "ok",
"get": {
"5b7e4b0b-fc98-4107-ab72-32577440e02e": {
"isUser": false,
"permissions": {
"play": true,
"disconnect": true,
"debug": false,
"color": false,
"leaderboard-collect-voice": true,
"view-bot-log": false,
"command-boobs": false,
"embed-builder": false,
"clear": false,
"admin": false,
"skip": true,
"w2g": true,
"pause": true,
"clear-queue": true,
"leaderboard": true,
"rank-self": true,
"rank-other": true,
"leaderboard-collect-text": true,
"queue": true,
"move-to-me": false
},
"id": 0
},
"d902f18f-95ad-432c-9ee9-27e63ff6fce1": {
"isUser": false,
"permissions": {
"play": false,
"disconnect": false,
"debug": false,
"color": false,
"leaderboard-collect-voice": false,
"view-bot-log": false,
"command-boobs": true,
"embed-builder": false,
"clear": false,
"admin": false,
"skip": false,
"w2g": false,
"pause": false,
"clear-queue": false,
"leaderboard": false,
"rank-self": false,
"rank-other": false,
"leaderboard-collect-text": false,
"queue": false,
"move-to-me": false
},
"id": 767965825293746217
}
}
}
But it seems if Chrome tries to get the data it gets in the response from the server the correct data but in the preview and the JavaScript of the site gets an wrong value. I tried to change the value but nothing works. It seems that every time the last 2 digits are replaced by zeros.
It has to do with how javascript is handling numbers. Even stored in a long, your number is still "too big" and can't be represented as a Javascript number. You'd be better off storing it as a string.
Check out this Stackoverflow subject for more details. Some people brought up alternative solutions.
say I have a file link in the format of something like
https://drive.google.com/uc?id=1o9rhnAr2GIilfjxPm4Wdl1BlaVP4Gsj1
Is it at all possible to get the email address of the one who uploaded this file, since the link is public? I haven't been able to find anything like this in the docs
File.get request
will return all the information about the file including the users email. I have altered it slightly but anyone running this request is going to get your email you might want to scramble that file id :)
All you need is an API key to be able to get information about a public file.
curl \
'https://www.googleapis.com/drive/v3/files/1o9rhnAr2GIilfjxPm4Wdl1BlaVP4Gsj1?fields=*&key=[YOUR_API_KEY]' \
--header 'Accept: application/json' \
--compressed
response
{
"kind": "drive#file",
"id": "1o9rhnAr2GIilfjxPm4Wdl1BlaVP4Gsj1",
"name": "pokemon_terrain.jpg",
"mimeType": "image/jpeg",
"starred": false,
"trashed": false,
"explicitlyTrashed": false,
"spaces": [
"drive"
],
"version": "5",
"webContentLink": "https://drive.google.com/uc?id=1o9rhnAr2GIilfjxPm4Wdl1BlaVP4Gsj1&export=download",
"webViewLink": "https://drive.google.com/file/d/1o9rhnAr2GIilfjxPm4Wdl1BlaVP4Gsj1/view?usp=drivesdk",
"iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg",
"hasThumbnail": true,
"thumbnailLink": "https://lh3.googleusercontent.com/1ZX-DvVSs70fPta2IAsg8tpYbkRDFeU0p-MVIdZPKY2PAGCGLqCAnXPl3MNMcafYNVfmAe2qips=s220",
"thumbnailVersion": "1",
"viewedByMe": false,
"createdTime": "2019-09-16T09:43:40.107Z",
"modifiedTime": "2020-02-13T14:12:57.036Z",
"modifiedByMe": false,
"owners": [
{
"kind": "drive#user",
"displayName": "p v",
"photoLink": "https://lh3.googleusercontent.com/a-/AOh14GjNKXej3SKi_Rc7VwlULYtsnN_A4uYJsxwoc_FR=s64",
"me": false,
"permissionId": "15907603398143100492",
"emailAddress": "vou.pandev#gmail.com"
}
],
"lastModifyingUser": {
"kind": "drive#user",
"displayName": "p v",
"photoLink": "https://lh3.googleusercontent.com/a-/AOh14GjNKXej3SKi_Rc7VwlULYtsnN_A4uYJsxwoc_FR=s64",
"me": false,
"permissionId": "15907603398143100492",
"emailAddress": "vourtspandev#gmail.com"
},
"shared": true,
"ownedByMe": false,
"capabilities": {
"canAddChildren": false,
"canAddMyDriveParent": false,
"canChangeCopyRequiresWriterPermission": false,
"canChangeViewersCanCopyContent": false,
"canComment": false,
"canCopy": false,
"canDelete": false,
"canDownload": true,
"canEdit": false,
"canListChildren": false,
"canModifyContent": false,
"canMoveChildrenWithinDrive": false,
"canMoveItemIntoTeamDrive": false,
"canMoveItemOutOfDrive": false,
"canMoveItemWithinDrive": false,
"canReadRevisions": false,
"canRemoveChildren": false,
"canRemoveMyDriveParent": true,
"canRename": false,
"canShare": false,
"canTrash": false,
"canUntrash": false
},
"viewersCanCopyContent": true,
"copyRequiresWriterPermission": false,
"writersCanShare": true,
"originalFilename": "pokemon_terrain.jpg",
"fullFileExtension": "jpg",
"fileExtension": "jpg",
"md5Checksum": "e7bb0cb361585f3845bd2a11e769c70b",
"size": "326467",
"quotaBytesUsed": "0",
"headRevisionId": "0BwYB7bTd8hGMd3A4WERUVHpuODNDdmM2MlZlNUNGQk9rc2hNPQ",
"imageMediaMetadata": {
"width": 460,
"height": 460,
"rotation": 0
}
}
I am creating project with JS, HTML, CSS and I am trying to makes my workflow faster and easier, so I decide to install browser-sync to help with auto-reloading page during coding process. And that would be great solution but browser-sync constantly after 30-60 sec reloading my page, what is annoying because during debugging when I change something in google chrome dev tools, like css properties, browser reload and changes gone. This is how I start browser-sync
browser-sync start --server --files .
And this is my bs-config.js
module.exports = {
"ui": {
"port": 3001,
"weinre": {
"port": 8080
}
},
"files": ["./css/*.css", "./scripts/*.js", "./*.html"],
"watchEvents": [
"change"
],
"watchOptions": {
"ignoreInitial": false
},
"server": false,
"proxy": false,
"port": 3000,
"middleware": false,
"serveStatic": [],
"ghostMode": {
"clicks": true,
"scroll": true,
"location": true,
"forms": {
"submit": true,
"inputs": true,
"toggles": true
}
},
"logLevel": "info",
"logPrefix": "Browsersync",
"logConnections": false,
"logFileChanges": true,
"logSnippet": true,
"rewriteRules": [],
"open": "local",
"browser": "default",
"cors": false,
"xip": false,
"hostnameSuffix": false,
"reloadOnRestart": false,
"notify": true,
"scrollProportionally": true,
"scrollThrottle": 0,
"scrollRestoreTechnique": "window.name",
"scrollElements": [],
"scrollElementMapping": [],
"reloadDelay": 0,
"reloadDebounce": 0,
"reloadThrottle": 0,
"plugins": [],
"injectChanges": true,
"startPath": null,
"minify": true,
"host": null,
"localOnly": false,
"codeSync": true,
"timestamps": true,
"clientEvents": [
"scroll",
"scroll:element",
"input:text",
"input:toggles",
"form:submit",
"form:reset",
"click"
],
"socket": {
"socketIoOptions": {
"log": false
},
"socketIoClientConfig": {
"reconnectionAttempts": 50
},
"path": "/browser-sync/socket.io",
"clientPath": "/browser-sync",
"namespace": "/browser-sync",
"clients": {
"heartbeatTimeout": 5000
}
},
"tagNames": {
"less": "link",
"scss": "link",
"css": "link",
"jpg": "img",
"jpeg": "img",
"png": "img",
"svg": "img",
"gif": "img",
"js": "script"
}
};
I didn't add any configs to it. I was trying to find solution but nothing help.
What I want is to reloading page only when I make and save changes to .htm, .css, .js files and I thought that is default behavior for browser-sync.
After update to tslint 5.0.0 i tried to run the follow command:
tslint -c tslint.json "src\app\**\*.ts"
This command, in version 4.5.1, return only the problems in typescript files(.ts). But now, returns the typescript (.ts) and html(.html) files.
UPDATE 1:
My tslint.json fille (I'm using codelyzer library too, so some rules belongs to codelyzer):
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": true,
"indent": [
true,
"spaces"
],
"label-position": true,
"max-line-length": [
true,
200
],
"member-access": false,
"member-ordering": [
true,
"static-before-instance",
"variables-before-functions"
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true,
"no-access-missing-member": true,
"templates-use-public": true,
"invoke-injectable": true
}
}