diff --git a/Share/GetData.js b/Share/GetData.js index 3cf4498..b326a32 100644 --- a/Share/GetData.js +++ b/Share/GetData.js @@ -21,39 +21,42 @@ MyPreprocessor.prototype = { } var url = document.URL - if (url.match(/youtube/) && time != "0") { + + // ログインせずに利用している人向け。ログインして使用している人の場合、↓の処理はバックエンドでやるのでいらない。 + var urlForLocalOnlyUser = document.URL + if (urlForLocalOnlyUser.match(/youtube/) && time != "0") { var video_id = document.URL.split('v=')[1]; var ampersandPosition = video_id.indexOf('&'); if(ampersandPosition != -1) { video_id = video_id.substring(0, ampersandPosition); } - url = "https://youtu.be/" + video_id + "?t=" + time; - } else if (url.match(/pornhub/) && time != "0") { - url = url + "&t=" + time - } else if (url.match(/nicovideo/) && time != "0") { - url = url + "?from=" + time - } else if (url.match(/dailymotion/) && time != "0") { - url = url + "?start=" + time + urlForLocalOnlyUser = "https://youtu.be/" + video_id + "?t=" + time; + } else if (urlForLocalOnlyUser.match(/pornhub/) && time != "0") { + urlForLocalOnlyUser = urlForLocalOnlyUser + "&t=" + time + } else if (urlForLocalOnlyUser.match(/nicovideo/) && time != "0") { + urlForLocalOnlyUser = urlForLocalOnlyUser + "?from=" + time + } else if (urlForLocalOnlyUser.match(/dailymotion/) && time != "0") { + urlForLocalOnlyUser = urlForLocalOnlyUser + "?start=" + time // } else if (url.match(/bilibili/) && time != "0") { // //機能しない // var video_id = document.URL.split('video/')[1]; // video_id = video_id.split('.html')[0]; // url = 'https://www.bilibili.com/video/' + video_id + "?t=" + time - } else if (url.match(/redtube/) && time != "0") { - url = url + "?t=" + time - } else if (url.match(/xhamster/) && time != "0") { + } else if (urlForLocalOnlyUser.match(/redtube/) && time != "0") { + urlForLocalOnlyUser = urlForLocalOnlyUser + "?t=" + time + } else if (urlForLocalOnlyUser.match(/xhamster/) && time != "0") { //アプリでは機能しない。safariで開くと機能する time = parseFloat(time) time = time.toFixed(2) - url = url + "?t=" + time - } else if (url.match(/tube8/) && time != "0") { - url = url + "?t=" + time - } else if (url.match(/twitch/) && time != "0") { + urlForLocalOnlyUser = urlForLocalOnlyUser + "?t=" + time + } else if (urlForLocalOnlyUser.match(/tube8/) && time != "0") { + urlForLocalOnlyUser = urlForLocalOnlyUser + "?t=" + time + } else if (urlForLocalOnlyUser.match(/twitch/) && time != "0") { // PCだといけるけどスマホだと機能しない var h = Math.floor(time / 3600); var m = Math.floor((time % 3600) / 60); var s = time % 60 - url = url + "?t=" + h + "h" + m + "m" + s + "s" + urlForLocalOnlyUser = urlForLocalOnlyUser + "?t=" + h + "h" + m + "m" + s + "s" } // 音声の再生位置を取得 @@ -111,10 +114,14 @@ MyPreprocessor.prototype = { } // ウィンドウサイズ - var iw = window.innerWidth; - var ih = window.innerHeight; - var ow = window.outerWidth; - var oh = window.outerHeight; + var wiw = window.innerWidth; + var wih = window.innerHeight; + var wow = window.outerWidth; + var woh = window.outerHeight; + + // オフセットサイズ + var ow = document.documentElement.offsetWidth; + var oh = document.documentElement.offsetHeight; // TODO: 変数名を合わせる arguments.completionFunction( @@ -131,10 +138,13 @@ MyPreprocessor.prototype = { "date": dateString, "videoPlaybackPosition": time, "audioPlaybackPosition": audioPlaybackPosition, - "windowInnerWidth": iw, - "windowInnerHeight": ih, - "windowOuterWidth": ow, - "windowOuterHeight": oh, + "windowInnerWidth": wiw, + "windowInnerHeight": wih, + "windowOuterWidth": wow, + "windowOuterHeight": woh, + "offsetWidth": ow, + "offsetHeight": oh, + "urlForLocalOnlyUser": urlForLocalOnlyUser, } ); }, diff --git a/Share/ShareViewController.swift b/Share/ShareViewController.swift index 7382c09..35fc9d8 100644 --- a/Share/ShareViewController.swift +++ b/Share/ShareViewController.swift @@ -94,6 +94,8 @@ class ShareViewController: SLComposeServiceViewController { let windowInnerHeight = results["windowInnerHeight"] as? Int let windowOuterWidth = results["windowOuterWidth"] as? Int let windowOuterHeight = results["windowOuterHeight"] as? Int + let offsetWidth = results["offsetWidth"] as? Int + let offsetHeight = results["offsetHeight"] as? Int let contentRequest = ContentRequest( title: title ?? "", url: url ?? "", @@ -113,7 +115,9 @@ class ShareViewController: SLComposeServiceViewController { windowInnerWidth: windowInnerWidth, windowInnerHeight: windowInnerHeight, windowOuterWidth: windowOuterWidth, - windowOuterHeight: windowOuterHeight + windowOuterHeight: windowOuterHeight, + offsetWidth: offsetWidth, + offsetHeight: offsetHeight ) self.contentManager.postContent( @@ -150,9 +154,9 @@ class ShareViewController: SLComposeServiceViewController { let maxScrollPositionYString: String = String( describing: maxScrollPositionY) - if results["url"] != nil { + if results["urlForLocalOnlyUser"] != nil { let resultsDic = [ - "url": results["url"], + "url": results["urlForLocalOnlyUser"], "title": results["title"], "positionX": scrollPositionXString, "positionY": scrollPositionYString, diff --git a/Shiori/Controllers/ViewController.swift b/Shiori/Controllers/ViewController.swift index e073609..3cd85fe 100644 --- a/Shiori/Controllers/ViewController.swift +++ b/Shiori/Controllers/ViewController.swift @@ -219,7 +219,7 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega // その他の場合 let webViewController = WebViewController() - webViewController.targetUrl = selectedContent.url + webViewController.targetUrl = selectedContent.sharingUrl webViewController.positionX = selectedContent.scrollPositionX ?? 0 webViewController.positionY = selectedContent.scrollPositionY ?? 0 webViewController.maxScroolPositionX = selectedContent.maxScrollPositionX ?? 0 diff --git a/Shiori/Model/Content/Content.swift b/Shiori/Model/Content/Content.swift index 83a660d..e529a40 100644 --- a/Shiori/Model/Content/Content.swift +++ b/Shiori/Model/Content/Content.swift @@ -38,6 +38,8 @@ struct Content: Codable { var windowInnerHeight: Int? var windowOuterWidth: Int? var windowOuterHeight: Int? + var offsetWidth: Int? + var offsetHeight: Int? enum CodingKeys: String, CodingKey { case id @@ -69,5 +71,7 @@ struct Content: Codable { case windowInnerHeight = "window_inner_height" case windowOuterWidth = "window_outer_width" case windowOuterHeight = "window_outer_height" + case offsetWidth = "offset_width" + case offsetHeight = "offset_height" } } diff --git a/Shiori/Model/Content/ContentRequest.swift b/Shiori/Model/Content/ContentRequest.swift index 9851d0f..139a0b2 100644 --- a/Shiori/Model/Content/ContentRequest.swift +++ b/Shiori/Model/Content/ContentRequest.swift @@ -29,6 +29,8 @@ struct ContentRequest: Codable { var windowInnerHeight: Int? var windowOuterWidth: Int? var windowOuterHeight: Int? + var offsetWidth: Int? + var offsetHeight: Int? enum CodingKeys: String, CodingKey { case title @@ -51,5 +53,7 @@ struct ContentRequest: Codable { case windowInnerHeight = "window_inner_height" case windowOuterWidth = "window_outer_width" case windowOuterHeight = "window_outer_height" + case offsetWidth = "offset_width" + case offsetHeight = "offset_height" } }