-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added userscript which uses coubdl-bridge's url scheme (you need to r…
…un `CoubDownload-Bridge.exe -register`, to unregister `CoubDownload-Bridge.exe -register false`
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"esversion": 6 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// ==UserScript== | ||
// @name Coub-Bridge | ||
// @namespace https://venipa.net | ||
// @version 0.1 | ||
// @description try to take over the world! | ||
// @author Venipa | ||
// @match https://*.coub.com/* | ||
// @match https://coub.com/* | ||
// @grant none | ||
// ==/UserScript== | ||
|
||
(function() { | ||
// 'use strict'; | ||
const downloadButton = function() { | ||
const btn = document.createElement('a'); | ||
btn.innerText = "Download Coub"; | ||
btn.style.padding = "8px 12px"; | ||
btn.style.color = "#fff"; | ||
btn.style.background = "#000"; | ||
btn.style.lineHeight = 1; | ||
btn.style.fontSize = "0.875rem"; | ||
btn.style.alignSelf = 'center'; | ||
btn.style.borderRadius = '4px'; | ||
btn.style.marginRight = '8px'; | ||
return btn; | ||
} | ||
var log = { | ||
debug: function(msg, ...params) { | ||
console.log('[coub-bridge|debug] ', msg, params); | ||
}, | ||
tag: function(tag, msg, ...params) { | ||
console.log('[coub-bridge|' + tag + '] ', msg, params); | ||
} | ||
}; | ||
log.debug('boot'); | ||
const buttonId = 'coubdl-download'; | ||
var checkCoubs = function() { | ||
var coubs = document.querySelectorAll('.coubs-list .coub[coub-block]:not(.timeline-banner), .coub-page > .coub-block-col .coub[coub-block]'); | ||
var coubRelated = document.querySelectorAll('.suggests-block-col .suggest__list > .suggest__item'); | ||
log.debug(coubs, coubRelated); | ||
|
||
coubs.forEach(function(x) { | ||
var controls = x.querySelector('.description__controls'); | ||
if (controls.querySelectorAll('#' + buttonId).length === 0) { | ||
var coubId = x.getAttribute('data-permalink'); | ||
var downloadBtn = downloadButton(); | ||
downloadBtn.id = buttonId; | ||
downloadBtn.href = "coubdl-bridge://" + coubId; | ||
controls.prepend(downloadBtn); | ||
} | ||
}); | ||
coubRelated.forEach(function(x) { | ||
if (x.querySelectorAll('#' + buttonId).length === 0) { | ||
var coubId = x.getAttribute('data-permalink'); | ||
var downloadBtn = downloadButton(); | ||
downloadBtn.id = buttonId; | ||
downloadBtn.href = "coubdl-bridge://" + coubId; | ||
downloadBtn.style.padding = '4px 6px'; | ||
downloadBtn.style.position = 'absolute'; | ||
downloadBtn.style.top = 0; | ||
downloadBtn.style.right = 0; | ||
downloadBtn.style.marginTop = '8px'; | ||
downloadBtn.style.marginRight = '8px'; | ||
downloadBtn.style.zIndex = 9999; | ||
x.prepend(downloadBtn); | ||
} | ||
}); | ||
}; | ||
var worker; | ||
var workerFunc = function() { | ||
clearInterval(worker); | ||
checkCoubs(); | ||
worker = setInterval(workerFunc, 2500); | ||
}; | ||
workerFunc(); | ||
log.debug(worker); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "coubdownload-bridge-sserscript", | ||
"version": "1.0.0", | ||
"main": "coub-bridge.user.js", | ||
"repository": "https://github.com/Venipa/coubdl-bridge", | ||
"author": "Venipa", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters