Last active
March 16, 2021 13:07
-
-
Save zuzu/7d894f53a181ba91118d01d4febd496b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- C:/etc/367968-zenzawatch-dev版.user.js Tue Mar 16 16:07:02 2021 | |
+++ C:/etc/423301-zenzawatch-dev版-20210316fix.user.js Tue Mar 16 16:07:02 2021 | |
@@ -1,5 +1,5 @@ | |
// ==UserScript== | |
-// @name ZenzaWatch DEV版 | |
+// @name ZenzaWatch DEV版 20210316fix | |
// @namespace https://github.com/segabito/ | |
-// @description ZenzaWatchの開発 先行バージョン | |
+// @description ZenzaWatchの開発 先行バージョンの20210315仕様変更対応版 | |
// @match *://www.nicovideo.jp/* | |
@@ -33,4 +33,4 @@ | |
// @grant none | |
-// @author segabito | |
-// @version 2.6.2 | |
+// @author zuzu0301 | |
+// @version 2.6.2.x | |
// @run-at document-body | |
@@ -6310,3 +6310,3 @@ | |
let isSwf = /\/smile\?s=/.test(videoUrl); | |
- let isDmc = watchApiData.flashvars.isDmc === 1 && dmcInfo.session_api; | |
+ let isDmc = watchApiData.flashvars.isDmc === 1 && dmcInfo.movie.session; | |
let csrfToken = watchApiData.flashvars.csrfToken; | |
@@ -6354,4 +6354,4 @@ | |
dmcInfo.quality = { | |
- audios: (dmcInfo.session_api || {audios: []}).audios.map(id => {return {id, available: true, bitrate: 64000};}), | |
- videos: (dmcInfo.session_api || {videos: []}).videos.reverse() | |
+ audios: (dmcInfo.movie.session || {audios: []}).audios.map(id => {return {id, available: true, bitrate: 64000};}), | |
+ videos: (dmcInfo.movie.session || {videos: []}).videos.reverse() | |
.map((id, level_index) => { return { | |
@@ -6398,4 +6398,4 @@ | |
const flvInfo = data.video.smileInfo || {}; | |
- const dmcInfo = data.video.dmcInfo || {}; | |
- const thumbnail = data.video.thumbnailURL + (hasLargeThumbnail ? '.L' : ''); | |
+ const dmcInfo = data.media.delivery || {}; | |
+ const thumbnail = data.video.thumbnail.largeUrl; | |
const videoUrl = flvInfo.url ? flvInfo.url : ''; | |
@@ -6405,8 +6405,8 @@ | |
const isSwf = /\/smile\?s=/.test(videoUrl); | |
- const isDmc = !!dmcInfo && !!dmcInfo.session_api; | |
- const csrfToken = data.context.csrfToken; | |
- const watchAuthKey = data.context.watchAuthKey; | |
+ const isDmc = !!dmcInfo && !!dmcInfo.movie.session; | |
+ const csrfToken = null; | |
+ const watchAuthKey = null; | |
const playlistToken = env.playlistToken; | |
const context = data.context; | |
- const commentComposite = data.commentComposite; | |
+ const commentComposite = data.comment; | |
const threads = commentComposite.threads.map(t => Object.assign({}, t)); | |
@@ -6422,10 +6422,7 @@ | |
}); | |
- const linkedChannelVideo = | |
- (context.linkedChannelVideos || []).find(ch => { | |
- return !!ch.isChannelMember; | |
- }); | |
- const isNeedPayment = context.isNeedPayment; | |
+ const linkedChannelVideo = false; | |
+ const isNeedPayment = false; | |
const defaultThread = threads.find(t => t.isDefaultPostTarget); | |
const msgInfo = { | |
- server: data.thread.serverUrl, | |
+ server: commentComposite.server.url, | |
threadId: defaultThread ? defaultThread.id : (data.thread.ids.community || data.thread.ids.default), | |
@@ -6438,5 +6435,7 @@ | |
threads, | |
- userKey: data.context.userkey, | |
- hasOwnerThread: data.thread.hasOwnerThread, | |
- when: null | |
+ userKey: data.comment.keys.userKey, | |
+ hasOwnerThread: threads.find(t => t.isOwnerThread), | |
+ when: null, | |
+ frontendId : env.frontendId, | |
+ frontendVersion : env.frontendVersion | |
}; | |
@@ -6447,3 +6446,3 @@ | |
const tagList = []; | |
- data.tags.forEach(t => { | |
+ data.tag.items.forEach(t => { | |
tagList.push({ | |
@@ -6452,3 +6451,3 @@ | |
tag: t.name, | |
- dic: t.isDictionaryExists, | |
+ dic: t.isNicodicArticleExists, | |
lock: t.isLocked, // 形式が統一されてない悲しみを吸収 | |
@@ -6462,3 +6461,3 @@ | |
channelInfo = { | |
- icon_url: data.channel.iconURL || '', | |
+ icon_url: data.channel.thumbnail.smallUrl || '', | |
id: data.channel.id, | |
@@ -6472,3 +6471,3 @@ | |
uploaderInfo = { | |
- icon_url: data.owner.iconURL, | |
+ icon_url: data.owner.iconUrl, | |
id: data.owner.id, | |
@@ -6481,3 +6480,3 @@ | |
videoDetail: { | |
- v: data.context.watchId, | |
+ v: data.client.watchId, | |
id: data.video.id, | |
@@ -6487,5 +6486,5 @@ | |
description_original: data.video.originalDescription, | |
- postedAt: data.video.postedDateTime, | |
- thumbnail: data.video.thumbnailURL, | |
- largeThumbnail: data.video.largeThumbnailURL, | |
+ postedAt: new Date(data.video.registeredAt).toLocaleString(), | |
+ thumbnail: data.video.thumbnail.url, | |
+ largeThumbnail: data.video.thumbnail.player, | |
length: data.video.duration, | |
@@ -6495,10 +6494,10 @@ | |
isChannel: data.channel && data.channel.id, | |
- isMymemory: data.context.isMyMemory, // 大文字小文字注意 | |
+ isMymemory: false, | |
communityId: data.community ? data.community.id : null, | |
- isPremiumOnly: data.context.isPremiumOnly, | |
- isLiked: data.context.isLiked, | |
+ isPremiumOnly: data.viewer.isPremiumOnly, | |
+ isLiked: data.video.viewer.like.isLiked, | |
channelId, | |
- commentCount: data.thread.commentCount, | |
- mylistCount: data.video.mylistCount, | |
- viewCount: data.video.viewCount, | |
+ commentCount: data.video.count.comment, | |
+ mylistCount: data.video.count.mylist, | |
+ viewCount: data.video.count.view, | |
tagList, | |
@@ -6552,4 +6551,4 @@ | |
resumeInfo: { | |
- initialPlaybackType: data.context.initialPlaybackType || '', | |
- initialPlaybackPosition: data.context.initialPlaybackPosition || 0 | |
+ initialPlaybackType: (data.player.initialPlayback? data.player.initialPlayback.type : ''), | |
+ initialPlaybackPosition: (data.player.initialPlayback? data.player.initialPlayback.positionSec : 0) | |
} | |
@@ -6742,2 +6741,5 @@ | |
let token = ''; | |
+ let xRequestWith = ''; | |
+ let xFrontendId = ''; | |
+ let xFrontendVersion = ''; | |
if (ZenzaWatch) { | |
@@ -7072,8 +7074,9 @@ | |
} | |
- async addMylistItem(watchId, groupId, description) { | |
- const url = 'https://www.nicovideo.jp/api/mylist/add'; | |
- let body = 'item_id=' + watchId + '&token=' + token + '&group_id=' + groupId; | |
+ async addMylistItem(watchId, groupId, description, frontendId, frontendVersion) { | |
+ //const url = 'https://www.nicovideo.jp/api/mylist/add'; | |
+ let body = 'itemId=' + watchId + '&description=';//+ '&token=' + token + '&group_id=' + groupId; | |
if (description) { | |
- body += '&description=' + encodeURIComponent(description); | |
+ body += encodeURIComponent(description); | |
} | |
+ const url = 'https://nvapi.nicovideo.jp/v1/users/me/mylists/' + groupId + '/items?' + body ; | |
const cacheKey = `mylistItems: ${groupId}`; | |
@@ -7081,4 +7084,4 @@ | |
method: 'POST', | |
- body, | |
- headers: { 'Content-Type': 'application/x-www-form-urlencoded'}, | |
+ //body, | |
+ headers: { 'X-Frontend-Id': frontendId, 'X-Frontend-Version': frontendVersion, 'X-Request-With': 'https://www.nicovideo.jp' }, | |
credentials: 'include' | |
@@ -7091,3 +7094,3 @@ | |
}); | |
- if (result.status && result.status === 'ok') { | |
+ if (result.meta.status && result.meta.status === 200) { | |
cacheStorage.removeItem(cacheKey); | |
@@ -7096,3 +7099,3 @@ | |
} | |
- if (!result.status || !result.error) { | |
+ if (!result.meta.status /*|| !result.error*/) { | |
throw new Error('マイリスト登録失敗(100)', {status: 'fail', result}); | |
@@ -7262,11 +7265,14 @@ | |
const PlaybackPosition = { | |
- record: (watchId, playbackPosition, csrfToken) => { | |
- const url = 'https://flapi.nicovideo.jp/api/record_current_playback_position'; | |
+ record: (watchId, playbackPosition, frontendId, frontendVersion) => { | |
+ const url = 'https://nvapi.nicovideo.jp/v1/users/me/watch/history/playback-position'; | |
const body = | |
- `watch_id=${watchId}&playback_position=${playbackPosition}&csrf_token=${csrfToken}`; | |
+ `watchId=${watchId}&seconds=${playbackPosition}`; | |
return netUtil.fetch(url, { | |
- method: 'POST', | |
+ method: 'PUT', | |
credentials: 'include', | |
headers: { | |
- 'Content-Type': 'application/x-www-form-urlencoded' | |
+ 'Content-Type': 'application/x-www-form-urlencoded', | |
+ 'X-Frontend-Id': frontendId, | |
+ 'X-Frontend-Version': frontendVersion, | |
+ 'X-Request-With': 'https://www.nicovideo.jp' | |
}, | |
@@ -7528,3 +7534,3 @@ | |
this._rawData = rawData; | |
- this._session = rawData.session_api; | |
+ this._session = rawData.movie.session; | |
} | |
@@ -7540,6 +7546,6 @@ | |
get videos() { | |
- return this._session.videos; | |
+ return this._rawData.movie.videos; | |
} | |
get quality() { | |
- return this._rawData.quality; | |
+ return this._rawData.movie.quality; | |
} | |
@@ -7552,15 +7558,15 @@ | |
get serviceUserId() { | |
- return this._session.service_user_id; | |
+ return this._session.serviceUserId; | |
} | |
get contentId() { | |
- return this._session.content_id; | |
+ return this._session.contentId; | |
} | |
get playerId() { | |
- return this._session.player_id; | |
+ return this._session.playerId; | |
} | |
get recipeId() { | |
- return this._session.recipe_id; | |
+ return this._session.recipeId; | |
} | |
get heartBeatLifeTimeMs() { | |
- return this._session.heartbeat_lifetime; | |
+ return this._session.heartbeatLifetime; | |
} | |
@@ -7573,3 +7579,3 @@ | |
get contentKeyTimeout() { | |
- return this._session.content_key_timeout; | |
+ return this._session.contentKeyTimeout; | |
} | |
@@ -7579,3 +7585,3 @@ | |
get authTypes() { | |
- return this._session.auth_types; | |
+ return this._session.authTypes; | |
} | |
@@ -7591,6 +7597,6 @@ | |
get transferPreset() { | |
- return (this._session.transfer_presets || [''])[0] || ''; | |
+ return (this._session.transferPresets || [''])[0] || ''; | |
} | |
get heartbeatLifeTime() { | |
- return this._session.heartbeat_lifetime || 120 * 1000; | |
+ return this._session.heartbeatLifetime || 120 * 1000; | |
} | |
@@ -7600,3 +7606,3 @@ | |
get trackingId() { | |
- return this._rawData.tracking_id || ''; | |
+ return this._rawData.trackingId || ''; | |
} | |
@@ -7683,3 +7689,3 @@ | |
this._msgInfo = info.msgInfo; | |
- this._dmcInfo = (info.dmcInfo && info.dmcInfo.session_api) ? new DmcInfo(info.dmcInfo) : null; | |
+ this._dmcInfo = (info.dmcInfo && info.dmcInfo.movie.session) ? new DmcInfo(info.dmcInfo) : null; | |
this._relatedVideo = info.playlist; // playlistという名前だが実質は関連動画 | |
@@ -7719,3 +7725,3 @@ | |
let url = this._flvInfo.url; | |
- if (!url.match(/smile\?m=/) || url.match(/^rtmp/)) { | |
+ if (!url || !url.match(/smile\?m=/) || url.match(/^rtmp/)) { | |
return null; | |
@@ -7765,3 +7771,3 @@ | |
get threadId() { // watchIdと同一とは限らない | |
- return this._videoDetail.thread_id; | |
+ return this._msgInfo.threadId; | |
} | |
@@ -23352,8 +23358,8 @@ | |
} | |
- navigator.mediaSession.metadata = new self.MediaMetadata({ | |
- title, | |
- artist, | |
- album, | |
- artwork | |
- }); | |
+ //navigator.mediaSession.metadata = new self.MediaMetadata({ | |
+ // title, | |
+ // artist, | |
+ // album, | |
+ // artwork | |
+ //}); | |
const nm = navigator.mediaSession; | |
@@ -25142,3 +25148,3 @@ | |
} | |
- this._mylistApiLoader.addMylistItem(watchId, groupId, description) | |
+ this._mylistApiLoader.addMylistItem(this._videoInfo.threadId, groupId, description, this._videoInfo.msgInfo.frontendId, this._videoInfo.msgInfo.frontendVersion ) | |
.then(result => this.execCommand('notify', `${result.message}: ${mylistName}`)) | |
@@ -25687,3 +25693,4 @@ | |
ct, | |
- vi.csrfToken | |
+ vi.msgInfo.frontendId, | |
+ vi.msgInfo.frontendVersion | |
).catch(e => { | |
@@ -32495,4 +32502,4 @@ | |
let availableVideos = | |
- dmcInfo.quality.videos.filter(v => v.available) | |
- .sort((a, b) => b.level_index - a.level_index); | |
+ dmcInfo.videos.filter(v => v.isAvailable) | |
+ .sort((a, b) => b.levelIndex - a.levelIndex); | |
let reg = VIDEO_QUALITY[this._videoQuality] || VIDEO_QUALITY.auto; | |
@@ -32524,3 +32531,8 @@ | |
if (dmcInfo.encryption){ | |
- parameters.encryption = dmcInfo.encryption; | |
+ parameters.encryption = { | |
+ hls_encryption_v1 : { | |
+ encrypted_key : dmcInfo.encryption.encryptedKey, | |
+ key_uri : dmcInfo.encryption.keyUri | |
+ } | |
+ }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment