Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.2.1 #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions Share/GetData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

// 音声の再生位置を取得
Expand Down Expand Up @@ -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(
Expand All @@ -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,
}
);
},
Expand Down
10 changes: 7 additions & 3 deletions Share/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "",
Expand All @@ -113,7 +115,9 @@ class ShareViewController: SLComposeServiceViewController {
windowInnerWidth: windowInnerWidth,
windowInnerHeight: windowInnerHeight,
windowOuterWidth: windowOuterWidth,
windowOuterHeight: windowOuterHeight
windowOuterHeight: windowOuterHeight,
offsetWidth: offsetWidth,
offsetHeight: offsetHeight
)

self.contentManager.postContent(
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Shiori/Controllers/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Shiori/Model/Content/Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
}
}
4 changes: 4 additions & 0 deletions Shiori/Model/Content/ContentRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
}