-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDesktop.qml
186 lines (157 loc) · 7.97 KB
/
Desktop.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Web 0.2
import com.canonical.Oxide 1.14 as Oxide
Page {
id: pageDesktop
visible: false
header: PageHeader {
id: pageHeader
title: i18n.tr("Fmessenger")
StyleHints {
foregroundColor: "#FFFFFF"
backgroundColor: "#0084FF"
dividerColor: "transparent"
}
leadingActionBar {
numberOfSlots:3
actions: [
Action {
id: actionForward
iconName: "go-next"
text: i18n.tr("Forward")
onTriggered: {
webview.goForward()
}
},
Action {
id: actionRestore
iconSource: "icon.svg"
iconName: "icon"
onTriggered: {
webview.url = 'https://www.messenger.com/'
}
text: qsTr("Messenger")
},
Action {
id: actionBack
iconName: "go-previous"
text: i18n.tr("Back")
onTriggered: {
webview.goBack()
}
}
]
}
trailingActionBar {
numberOfSlots: 2
actions: [
Action {
id: actionDesktop
iconName: "computer-symbolic"
text: i18n.tr("Desktop view")
},
Action {
id: actionMain
iconName: "go-previous"
text: i18n.tr("Device selection")
onTriggered: {
onClicked: mainPageStack.pop(pageDesktop)
}
},
Action {
id: actionfacebook
iconName: "facebook-symbolic"
text: i18n.tr("Go to facebook")
onTriggered: {
webview.url = 'https://www.facebook.com/'
}
}
]
}
}
WebContext {
id: webcontext
userAgent: myUA
userScripts: [
Oxide.UserScript {
context: "oxide://"
url: Qt.resolvedUrl("./userscripts/desktop.js")
matchAllFrames: true
}
]
}
WebView {
id: webview
anchors {
fill: parent
bottom: parent.bottom
top: pageHeader.bottom
topMargin: units.gu(6)
}
context: webcontext
url: "https://www.messenger.com/login.php"
preferences.localStorageEnabled: true
preferences.allowFileAccessFromFileUrls: true
preferences.allowUniversalAccessFromFileUrls: true
preferences.appCacheEnabled: true
preferences.javascriptCanAccessClipboard: true
filePicker: filePickerLoader.item
function navigationRequestedDelegate(request) {
var url = request.url.toString();
var pattern = myPattern.split(',');
var isvalid = false;
if (Conf.hapticLinks) {
vibration.start()
}
if (Conf.audibleLinks) {
clicksound.play()
}
for (var i=0; i<pattern.length; i++) {
var tmpsearch = pattern[i].replace(/\*/g,'(.*)')
var search = tmpsearch.replace(/^https\?:\/\//g, '(http|https):\/\/');
if (url.match(search)) {
isvalid = true;
break
}
}
if(isvalid == false) {
console.warn("Opening remote: " + url);
Qt.openUrlExternally(url)
request.action = Oxide.NavigationRequest.ActionReject
}
}
Component.onCompleted: {
preferences.localStorageEnabled = true
if (Qt.application.arguments[1].toString().indexOf(myUrl) > -1) {
console.warn("got argument: " + Qt.application.arguments[1])
url = Qt.application.arguments[1]
}
console.warn("url is: " + url)
}
onGeolocationPermissionRequested: { request.accept() }
Loader {
id: filePickerLoader
source: "ContentPickerDialog.qml"
asynchronous: true
}
}
ThinProgressBar {
webview: webview
anchors {
left: parent.left
right: parent.right
top: pageHeader.bottom
}
}
Connections {
target: UriHandler
onOpened: {
if (uris.length === 0 ) {
return;
}
webview.url = uris[0]
console.warn("uri-handler request")
}
}
}