From b962354d561bb9699fb6cb625f8029fe17a8ccae Mon Sep 17 00:00:00 2001 From: masatora Date: Sat, 15 Jan 2022 17:44:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?offsetWidth/Height=E3=82=92=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Share/GetData.js | 22 ++++++++++++------- Share/ShareViewController.swift | 6 ++++- .../xcschemes/xcschememanagement.plist | 4 ++-- Shiori/Model/Content/Content.swift | 4 ++++ Shiori/Model/Content/ContentRequest.swift | 4 ++++ 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Share/GetData.js b/Share/GetData.js index 3cf4498..b2fd400 100644 --- a/Share/GetData.js +++ b/Share/GetData.js @@ -111,10 +111,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 +135,12 @@ 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, } ); }, diff --git a/Share/ShareViewController.swift b/Share/ShareViewController.swift index 7382c09..d601ab7 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( diff --git a/Shiori.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist b/Shiori.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist index 2edfb0f..5d432bb 100644 --- a/Shiori.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Shiori.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,12 +12,12 @@ Share.xcscheme_^#shared#^_ orderHint - 25 + 24 Shiori.xcscheme_^#shared#^_ orderHint - 24 + 25 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" } } From 2e27f6c79379188421451c8ae67dd0df0a023405 Mon Sep 17 00:00:00 2001 From: masatora Date: Mon, 17 Jan 2022 04:27:56 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8B=95=E7=94=BB=E5=86=8D=E7=94=9F?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E3=81=AE=E8=AA=BF=E6=95=B4=E3=82=92=E3=83=90?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=A8=E3=83=B3=E3=83=89=E3=81=AB=E7=A7=BB?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Share/GetData.js | 36 ++++++++++--------- Share/ShareViewController.swift | 4 +-- .../xcschemes/xcschememanagement.plist | 4 +-- Shiori/Controllers/ViewController.swift | 2 +- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Share/GetData.js b/Share/GetData.js index b2fd400..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" } // 音声の再生位置を取得 @@ -141,6 +144,7 @@ MyPreprocessor.prototype = { "windowOuterHeight": woh, "offsetWidth": ow, "offsetHeight": oh, + "urlForLocalOnlyUser": urlForLocalOnlyUser, } ); }, diff --git a/Share/ShareViewController.swift b/Share/ShareViewController.swift index d601ab7..35fc9d8 100644 --- a/Share/ShareViewController.swift +++ b/Share/ShareViewController.swift @@ -154,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.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist b/Shiori.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist index 5d432bb..2edfb0f 100644 --- a/Shiori.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Shiori.xcodeproj/xcuserdata/MasatoraAtarashi.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,12 +12,12 @@ Share.xcscheme_^#shared#^_ orderHint - 24 + 25 Shiori.xcscheme_^#shared#^_ orderHint - 25 + 24 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