mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 09:08:37 +02:00
Injected script to remove other file types from download options
This commit is contained in:
parent
d16ef521f4
commit
b131338dd0
3 changed files with 30 additions and 19 deletions
|
@ -25,27 +25,19 @@ Rectangle {
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
id: marketplace
|
id: marketplace
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property var currentUrl: "https://metaverse.highfidelity.com/marketplace"
|
property var marketplacesUrl: "../../scripts/system/html/marketplaces.html"
|
||||||
property int statusBarHeight: 50
|
property int statusBarHeight: 50
|
||||||
property int statusMargin: 50
|
property int statusMargin: 50
|
||||||
|
property string standardMessage: "Check out other marketplaces"
|
||||||
|
property string claraMessage: "Choose a model from the list and click Download -> Autodesk FBX"
|
||||||
|
|
||||||
Controls.BaseWebView {
|
Controls.BaseWebView {
|
||||||
id: webview
|
id: webview
|
||||||
url: currentUrl
|
url: marketplacesUrl
|
||||||
anchors.top: marketplace.top
|
anchors.top: marketplace.top
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - statusBarHeight
|
height: parent.height - statusBarHeight
|
||||||
focus: true
|
focus: true
|
||||||
newWindowHook: function (component, newWindow) {
|
|
||||||
if (File.isZippedFbx(desktop.currentUrl)) {
|
|
||||||
runJavaScript(autoCancel);
|
|
||||||
zipTimer.handler = function() {
|
|
||||||
console.log("timer started", newWindow)
|
|
||||||
newWindow.destroy();
|
|
||||||
}
|
|
||||||
zipTimer.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: zipTimer
|
id: zipTimer
|
||||||
|
@ -63,13 +55,24 @@ Rectangle {
|
||||||
element.removeClass("download-file");
|
element.removeClass("download-file");
|
||||||
element.removeAttr("download");'
|
element.removeAttr("download");'
|
||||||
|
|
||||||
|
property var checkFileType: "$('[data-extension]:not([data-extension=\"fbx\"])').parent().remove()"
|
||||||
|
|
||||||
onLinkHovered: {
|
onLinkHovered: {
|
||||||
desktop.currentUrl = hoveredUrl;
|
desktop.currentUrl = hoveredUrl;
|
||||||
// add an error message for non-fbx files
|
if (File.isClaraLink(desktop.currentUrl)) {
|
||||||
if (File.isZippedFbx(desktop.currentUrl)) {
|
//runJavaScript(checkFileType, function(){console.log("Remove filetypes JS injection");});
|
||||||
runJavaScript(simpleDownload, function(){console.log("ran the JS");});
|
if (File.isZippedFbx(desktop.currentUrl)) {
|
||||||
}
|
runJavaScript(simpleDownload, function(){console.log("Download JS injection");});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadingChanged: {
|
||||||
|
if (File.isClaraLink(webview.url)) {
|
||||||
|
statusLabel.text = claraMessage;
|
||||||
|
} else {
|
||||||
|
statusLabel.text = standardMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,8 +92,10 @@ Rectangle {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
width: 150
|
width: 150
|
||||||
text: "See all markets"
|
text: "See all markets"
|
||||||
//onClicked: webview.url = "file:///E:/GitHub/hifi/scripts/system/html/marketplaces.html"
|
onClicked: {
|
||||||
onClicked: webview.url = "../../scripts/system/html/marketplaces.html"
|
webview.url = "../../scripts/system/html/marketplaces.html";
|
||||||
|
statusLabel.text = standardMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
|
@ -99,7 +104,7 @@ Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: statusMargin
|
anchors.leftMargin: statusMargin
|
||||||
color: hifi.colors.white
|
color: hifi.colors.white
|
||||||
text: "Check out other marketplaces"
|
text: standardMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
|
|
|
@ -69,6 +69,11 @@ bool FileScriptingInterface::isTempDir(QString tempDir) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileScriptingInterface::isClaraLink(QUrl url) {
|
||||||
|
if (url.toString().contains("clara") && !url.toString().contains("clara.io/signup")) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool FileScriptingInterface::isZippedFbx(QUrl url) {
|
bool FileScriptingInterface::isZippedFbx(QUrl url) {
|
||||||
if (url.toString().contains(".zip") && url.toString().contains("fbx")) return true;
|
if (url.toString().contains(".zip") && url.toString().contains("fbx")) return true;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool isZippedFbx(QUrl url);
|
bool isZippedFbx(QUrl url);
|
||||||
|
bool isClaraLink(QUrl url);
|
||||||
QString convertUrlToPath(QUrl url);
|
QString convertUrlToPath(QUrl url);
|
||||||
void runUnzip(QString path, QUrl url);
|
void runUnzip(QString path, QUrl url);
|
||||||
QString getTempDir();
|
QString getTempDir();
|
||||||
|
|
Loading…
Reference in a new issue