User talk:Erutuon/scripts/ScriptInstaller.js

Latest comment: 4 years ago by Erutuon in topic Does it work with monobook?

When viewing an installed script, instead of showing "Installed", why not make an uninstall button? Also, could you change deprecated stuff (like global variable wgPageName etc.) to newer replacements. Also, don't repeat Equazcion's mistake by not adding wikt: prefix to the link in the summary text it generates when installing. P.S. it does not work for me. --Dixtosa (talk) 09:32, 21 May 2017 (UTC)Reply

Do you have any error in your console that would indicate why it isn't working?
I removed the deprecated variables. I'm not immediately sure which link you're referring to, but I'll look for it. — Eru·tuon 18:43, 21 May 2017 (UTC)Reply
No. It seems to work only on the pages that are already installed and the script is linked. Your script is the only local script that isn't linked back from my common.js and coincidentally it is the only script for which the buttons don't show up at all.
Please do make sure to make an uninstall button as I have stated above. It should be easy.
Also clicking the script link (left to the "uninstall" button) in the opened panel of installed scripts starts uninstalling and fails.
The link I am referring is the red link in diffs like these.
There's one more line generating deprecated warning (variables wgPageContentLanguage and wgNoticeProject). Dixtosa (talk) 19:08, 21 May 2017 (UTC)Reply
I've fixed the uninstall button on the list of scripts, and it can now uninstall any script added with importScript(). Now I'm trying to figure out how to add the uninstall button. — Eru·tuon 19:57, 21 May 2017 (UTC)Reply
Added the uninstall button... but it appears even when the script isn't installed. Gotta fix that. — Eru·tuon 20:40, 21 May 2017 (UTC)Reply
Fixed the uninstall button. Not happy with how the links display. The CSS could be improved. — Eru·tuon 21:49, 21 May 2017 (UTC)Reply
I like it thank you. Though there are couple of things you you many want to consider.
  1. The best way to determine if the script is importable (or loadable) is probably by checking wgPageContentModel variable not by pageName.lastIndexOf('.js').
  2. The part where it excludes users' own common.js and skin.js pages it also excludes this page which is weird and unnecessary.
  3. The following line and the else statement right after the block seem unnecessary to me. This line causes manual installation alert to pop up and I do not see why any page with javascript content model could not be installed automatically.
    if (((path.toLowerCase().substring(0, 5) == "user:") || (path.toLowerCase().substring(0,10) == 'wikipedia:')) && (path.lastIndexOf('.js') == path.length - 3))
    
  4. Probably not run on talk pages of scripts? I am not too sure about that.Dixtosa (talk) 19:04, 23 May 2017 (UTC)Reply
I think the contentModel idea is good, so I immediately implemented it. It prevents the script from running on this talk page, which is good because it doesn't contain any usable JavaScript code. — Eru·tuon 19:12, 23 May 2017 (UTC)Reply
  • I have installed this on wiki and CSS were not fetched I guess you should use mw.loader instead of importStylesheet. Dixtosa (talk) 21:12, 26 May 2017 (UTC)Reply
    @Dixtosa: I've switched to mw.loader.load, with the pagename, but I don't know if that works or if I have to use the URL. — Eru·tuon 21:36, 26 May 2017 (UTC)Reply
    You'll have to tell me how to use mw.loader for CSS, because I don't know and can't seem to find a documentation page that explains it. It's frustrating how bad the documentation for mw stuff is, or maybe I'm just not proficient enough in programming. — Eru·tuon 21:42, 26 May 2017 (UTC)Reply
    @Dixtosa: Is mw.loader.load("User:Erutuon/ScriptInstaller.css") supposed to work? I tried it, but didn't see the styles when I loaded a JS page. — Eru·tuon 23:20, 26 May 2017 (UTC)Reply
    No, not specifying the server is the old and deprecated method (like importScript). mw.loader was probably designed to be unambiguous and let userscripts be adjusted to other projects easily (or at no cost).
    This works: importStylesheetURI("//en.wiktionary.org/w/index.php?title=User:Erutuon/ScriptInstaller.css&action=raw&ctype=text/css")--Dixtosa (talk) 23:25, 26 May 2017 (UTC)Reply

Does it work with monobook?

edit

--So9q (talk) 13:34, 1 September 2019 (UTC)Reply

@So9q: I think so. I used to use MonoBook. — Eru·tuon 16:11, 1 September 2019 (UTC)Reply
Return to the user page of "Erutuon/scripts/ScriptInstaller.js".