Greasy Fork is available in English.

議論 » 開発

CSS to Script Converter

§
投稿日: 2015/09/19
編集日: 2017/04/16

CSS to Script Converter

Hey guys. So recently I have developed a small utility to convert CSS to Userscripts since I can't seem to find one that already exists.

Features:
- Convert CSS to Userscripts
- GreaseMonkey and TamperMonkey support.
- Simple user interface.

I hope you guys will find this tool helpful!

Repo: https://github.com/Spiderpig86/CSStoUserScriptConverter

Requirements: Windows XP SP3 or above.
(Sorry OSX/Linux users) :(

§
投稿日: 2015/09/24

Woo download link has been added.

§
投稿日: 2015/09/24

awesome work, thank you, this will be useful!

§
投稿日: 2015/09/24

Seems Ok, if "Chrome" Checked.

But don't work if "Firefox" checked:
It copy just the CSS in the generated script place...

Can you give us what this version provide new.
I observe "just" a new design and the browser option.

.... I know i ask you that previously :
And option to directly convert an Userstyles ???
:-)

§
投稿日: 2015/09/24
編集日: 2015/09/24

I'll look more into this issue. Thanks for the report. So far I have not found the time to implement reversing Userscripts into plain CSS. I will also try to implement that in the future.

PS: @decembre Those are pretty much the only changes in 1.0.1. I will attach a changelog in the future.

§
投稿日: 2015/09/25

I'm really confused as to what the issue is. I've tested the converter to target Firefox with Stylish and everything works.

§
投稿日: 2015/09/26

I have retested:
I don't know, but , for my , if i use the firefox option, that's give only the CSS i provide...
Strange...

i am on win7 64bits

§
投稿日: 2015/09/27

Can you give me a sample of what a userstyle should look like on Firefox?

§
投稿日: 2015/09/27
編集日: 2015/09/27

by example (for your username in this forum):

.Username[href$="/forum/profile/5720/Stanley%20Lim"] {
border-radius: 5px !important;
padding: 5px !important;
background: red !important;
}


give (with "Chrome" option) :

// ==UserScript==
// @name STY - TEST - For CSS to Script Converter
// @description STY - TEST - For CSS to Script Converter
// @author decembre
// @homepage greasyfork.org
// @include greasyfork.org
// @version v.1
// ==/UserScript==
(function() {var css = [".Username[href$='/forum/profile/5720/Stanley%20Lim'] {",
"border-radius: 5px !important;",
"padding: 5px !important;",
"background: red !important;",
"}"
].join("\n");
if (typeof GM_addStyle != 'undefined') {
GM_addStyle(css);
} else if (typeof PRO_addStyle != 'undefined') {
PRO_addStyle(css);
} else if (typeof addStyle != 'undefined') {
addStyle(css);
} else {
var node = document.createElement('style');
node.type = 'text/css';
node.appendChild(document.createTextNode(css));
var heads = document.getElementsByTagName('head');
if (heads.length > 0) { heads[0].appendChild(node);
} else {
// no head yet, stick it whereever
document.documentElement.appendChild(node);
}
}})();


With firefox option:
that's just the original CSS without any change....

§
投稿日: 2015/09/30

But there is a change when you use the Firefox option. It specifies that it is meant to be rendered for Firefox. I've tested conversions from CSS to Userscripts for Firefox and tried it out in GeaseMonkey and Stylish and both worked.

§
投稿日: 2015/10/01

strange...

§
投稿日: 2015/10/19

Now it work for Chrome ...
I don't know why but work !
:-)
A question:
How to use your tool for a style which have some different CSS for different domain or pref url ?

§
投稿日: 2017/03/29

Hey does anyone still have a copy of this they could send me or post an updated link since his original dropbox link is dead?

§
投稿日: 2017/04/16
Hey does anyone still have a copy of this they could send me or post an updated link since his original dropbox link is dead?

Sorry for the inactivity and thanks for reporting the broken link. An update rolled out and this time I put the application on Github. If there are any issues, please report it there.

§
投稿日: 2017/04/17

How to install it ?

§
投稿日: 2017/05/07
How to install it ?

You can download the project at https://github.com/Spiderpig86/CSStoUserScriptConverter/releases . The .exe is portable so you can run it anywhere after you extract it. It should be in ./CSStoUserScript/bin/Release/CSStoUserScript.exe

§
投稿日: 2017/05/08

Thanks !

§
投稿日: 2017/05/08
編集日: 2017/05/08
A question:
How to use your tool for an userststyle which have some different CSS for different domain or pref url ?

by example my userstyle:
Userstyles TableView+Enhancer - Dark-Grey
Use these:

@-moz-document domain("userstyles.org")
, domain("greasyfork.org")
, domain("sleazyfork.org")
, url-prefix("https://greasyfork.org/forum/") ,
url-prefix("https://74.86.192.75/")

@-moz-document url-prefix("https://userstyles.org/")
@-moz-document url-prefix("https://forum.userstyles.org")
@-moz-document url-prefix("https://userstyles.org/help")
@-moz-document domain("sleazyfork.org")
@-moz-document url-prefix("https://greasyfork.org/fr/scripts/19838-diep-io-by-terjanq")

For firefox, what i need to use as @include?
If i use all al them i can have some problem because by example i don't want use the same
CSS for usertyle.or or greasyfor.org.

Chrome need a separate block for each domain or url-prefix

§
投稿日: 2018/12/25

Any news ?

§
投稿日: 2019/06/27

Wow it's been a while. Anyway, I noticed that there was some renewed interest in this tool recently. I can see if I have time to update the tool and create a cross-platform version (using Electron for example). Please let me know of any issues and missing features.

§
投稿日: 2019/06/28

I test your tool when you have a new version :smile:

§
投稿日: 2019/08/04

I think, you can do like this:

// ==UserScript==
// @name         InsertUserCSS
// @include      *://example.com/*
// ==/UserScript==
'use strict'

document.body.insertAdjacentHTML('beforeend', `<style>

body {
  background: #000;
}

</style>`)
§
投稿日: 2019/08/05

@kkocdko a dit : I think, you can do like this...

Thanks, but it seems not working with "complexe" usertyles (pref-url, etc) In chrome, I test it with my userstyle: Userstyles / Greasy Fork Enhancer Dark-Grey I inserted its code between

§
投稿日: 2019/12/28

no news ?

返信を投稿

返信を投稿するにはログインしてください。