Skip to content

Instantly share code, notes, and snippets.

@stokito
Last active April 17, 2024 13:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokito/a7babfa3c04c92c6c4142581145fe33d to your computer and use it in GitHub Desktop.
Save stokito/a7babfa3c04c92c6c4142581145fe33d to your computer and use it in GitHub Desktop.
WebDAV User Script for Violentmonkey, Tampermonkey and Greasemonkey

WebDAV User Script for Tampermonkey, Greasemonkey and Violentmonkey

Browse a URL as a WebDAV share. With the Tampermonkey extension on Firefox Mobile you can use it from phone.

screenshot

Open WebDAV folder in a browser and you'll have ether 403 error or just a plain directory listing.
Then click on the addon button and it will make a file manager from the folder where you can watch, upload, delete files and direcotries.

The script automatically enables for any url that have /dav/ e.g. http://example.com/dav/ prefix or dav. subdomaain e.g. http://dav.example.com/.

It just uses the https://github.com/dom111/webdav-js
But instead of a bookmarklet you can use it as an extension.

Chrome Extension

See also

// ==UserScript==
// @name WebDAV Browser
// @name:ru WebDAV обозреватель
// @version 0.1.1
// @description Browse WebDAV share directly from a browser
// @description:ru Позволяет просмотреть WebDAV папку прямо из браузера
// @license 0BSD
// @author Sergey Ponomarev <stokito@gmail.com>
// @namespace https://gist.github.com/stokito/a7babfa3c04c92c6c4142581145fe33d
// @supportURL https://gist.github.com/stokito/a7babfa3c04c92c6c4142581145fe33d
// @updateURL https://gist.githubusercontent.com/stokito/a7babfa3c04c92c6c4142581145fe33d/raw/WebDAV.user.js
// @downloadURL https://gist.githubusercontent.com/stokito/a7babfa3c04c92c6c4142581145fe33d/raw/WebDAV.user.js
// @match http://*/dav/*
// @match https://*/dav/*
// @match http://dav.*/*
// @match https://dav.*/*
// @match http://*/webdav/*
// @match https://*/webdav/*
// @match http://webdav.*/*
// @match https://webdav.*/*
// @match http://*/*remote.php/dav/files/*
// @match https://*/*remote.php/dav/files/*
// @match http://*/*remote.php/webdav*
// @match https://*/*remote.php/webdav*
// @match http://*/*seafdav/*
// @match https://*/*seafdav/*
// @match https://sd2dav.1und1.de/
// @match https://svn.*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log("Clear existing body if any")
document.body.innerHTML = ""
var style = document.createElement("link")
style.rel = "stylesheet"
style.href = "https://cdn.jsdelivr.net/gh/dom111/webdav-js/assets/css/style-min.css"
document.head.appendChild(style)
var script = document.createElement("script")
script.src = "https://cdn.jsdelivr.net/gh/dom111/webdav-js/src/webdav-min.js"
document.head.appendChild(script)
})();
@stokito
Copy link
Author

stokito commented Mar 28, 2023

Doesn't work for NextCloud "Refused to load the stylesheet because it violates the following Content Security Policy directive: "default-src 'none'"
So it can't inject CSS or JS. Workaround with https://wiki.greasespot.net/Metadata_Block#@resource doesn't work too because data: and blob: are blocked too

@stokito
Copy link
Author

stokito commented Mar 28, 2023

TODO match by @include because we can't match by subdomain dav.*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment