// ==UserScript==
// @name Greasy Fork Install Button at search
// @namespace -
// @version 0.5.0
// @description adds install button at search and at user pages.
// @author NotYou
// @include *sleazyfork.org/*
// @include *greasyfork.org/*
// @grant none
// @run-at document-idle
// @license GPL-3.0-or-later
// @downloadURL none
// ==/UserScript==
/*
﹀ Change Log ﹀
0.5.0 Version:
- jQuery to Pure JS
0.4.1-extra Version:
- Added libraries support at user pages
0.4 Version:
- Removed HTTP support
- Added libraries support
0.3 Version:
- SleazyFork support
- HTTP support
0.2 Version:
- Better css styles identifying
*/
var $ = (s) => document.querySelector(s)
var $$ = (s) => document.querySelectorAll(s)
Element.prototype.appendHTML = function(html) {
this.insertAdjacentHTML('beforeend', html)
}
var domain = location.host
// STYLES
$('head').appendHTML(``)
// USER SCRIPT
$$('#user-script-list > li[data-script-type="public"] > article > h2 > a, #browse-script-list > li[data-script-type="public"] > article > h2 > a').forEach(function(e) {
let scriptId = e.parentNode.parentNode.parentNode.dataset.scriptId, scriptName = e.parentNode.parentNode.parentNode.dataset.scriptName
e.appendHTML('Install')
})
// USER STYLE
$$('#user-script-list > li[data-script-language="css"] > article > h2 > a, #browse-script-list > li[data-script-language="css"] > article > h2 > a').forEach(function(e) {
let scriptId = e.parentNode.parentNode.parentNode.dataset.scriptId
let scriptName = e.parentNode.parentNode.parentNode.dataset.scriptName
e.appendHTML('Install as style')
})
// LIBRARIES
$$('#user-library-script-list > li > article > h2 > a, #browse-script-list > li[data-script-type="library"] > article > h2 > a').forEach(function(e) {
let scriptId = e.parentNode.parentNode.parentNode.dataset.scriptId, scriptName = e.parentNode.parentNode.parentNode.dataset.scriptName, scriptNameFinal = scriptName.replace(/\s/g, "-")
e.appendHTML('Copy URL')
})