quoid / userscripts Goto Github PK
View Code? Open in Web Editor NEWAn open-source userscript manager for Safari
Home Page: https://quoid.github.io/userscripts/
License: GNU General Public License v3.0
An open-source userscript manager for Safari
Home Page: https://quoid.github.io/userscripts/
License: GNU General Public License v3.0
From a Reddit comment:
The editor's broken in Catalina at the moment, but if you can populate the JSON in ~/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/data.json it works regardless
I am not and won't be on the dev beta, but if any user(s) is on Catalina and check the console of the popover (right click, inspect) to see if that's where the bug is emanating from, it would be appreciated.
Right now the javascript is saved, escaped, in a json
file - along with the lastEdited
date.
Saving the script is a normal js file will make editing outside of the included editor a much easier process. Saving the lastEdited
date isn't needed as well, since we can get the modificationDate
via FileManager
in swift.
Possibly through the use of an intermediate loading view
in progress
Encountered issues:
UserDefaults
isn't created at first launch, so forced to click toggle on first use
!= "off"
UserDefaults
on first launchAllows users to change specific features with the use of a custom metadata block within the editor. This will pave the way for parsing TM and GM script metadata in the future when multiple script functionality is potentially added.
Syntax concept:
/*options @tabSize: 2; @whiteSpace: true; */
Code level improvements can be made throughout all of the files, including Swift, Javascript, HTML and CSS. The main reasons I want to do this is to hopefully make the code more maintainable and understandable - it is also a necessary requirement for other v1.4.0 features.
Sometimes my pages doesn’t load with the code and have to refresh the page. (MacOs Catalina)
Support for additional languages, firstly focusing on the following languages because I have resources for these:
UserScripts have at the top a block to set the metadata. When a UserScript manager parses the UserScript, reads this block to do things like:
As you can see, the implementation of "just the metadata block" involves quite lot of features at the same time. Each feature may be looks by its own. Some of these may be included in a v2 and some in a v3 (if they even happen).
I just wanted to flag these topics so they can be discussed and users (of this plugin) can notice what's the priority around them.
If a user manually removes a script file from the scripts folder, its entries in the manifest persist.
Should clean/purge manifest of non-existent scripts on updateScriptsData
that gets fired on app load.
Currently, even if the editor has no last saved date, the text in the status area changes to "Last edited on" - this should not be the case.
If the there is no "lastEdited" date, the text should stay at default, Ready for code...
.
Codemirror is suggesting functions from the editor javascript. It would be best if it didn't do that.
Unfortunately, I can not wrap the code (like it was done previously) or the native code won't be able to access the wrapped functions, which is necessary for some functionality (example).
Perhaps we can omit this variables and functions from Codemirror...
It might be useful to be able to have multiple userscripts tied to particular domains. Is this something that fits within the scope of this app?
From #14
Since UserDefaults
isn't created at first launch, script injection doesn't occur until the user clicks the toggle button on/
off` - the default behavior should be that script injection occurs as default.
Version 2 requires Safari to be version 13+ in order to function.
Safari 13+ is available on macOS 10.13-current. Because of this, version 2 is available for macOS 10.13 and above. However, some users might not have updated their browsers and actively might not want to update their browsers. This would make the extension incompatible with their Safari version, but compatible with their OS version.
One solution would be to required macOS 10.15 and above for Userscripts Safari Version 2.0.0+, since all users of that macOS version will have Safari 13.
Another solution would be to make a simple error popup when the safari
object inaccessible (which indicated a Safari version < 13).
The latter of those two options is preferable.
Reference: #48
Hello, is there a way I am get this onto my iPad os? iPad OS gives us desktop safari on iPad. When I click the link to Apple App Store, the get icon is shaded it.
Thankyou for your help
When attempting to download the script while in a webpage that has child pages with HTML sources, the script download will trigger multiple times (as many child pages/sources there are).
Need to add something to script.js like if (window.top === window) {}
to prevent this from happening.
System Information:
macOS version 10.15.6(19G73)
userscripts version 2.0.0
Safari version 13.1.2(15609.3.5.1.3)
I noticed this when testing user scripts on website hosted on localhost.
// ==UserScript==
// @name qwertyuiop513135
// @description This is your new userscript, start writing code
// @match *://localhost/*
// ==/UserScript==
window.location.assign('https://www.google.com/search?q=Success')
mkdir qwertyuiop513135;
cd qwertyuiop513135;
echo '<html></html>\n' > test.html;
http://localhost/test.html
. Safari should not be able to reach to server.qwertyuiop513135
directory, run this command:nc -kl 80 < test.html;
test.html
, a panel will appear.nc -kl 80 < test.html;
by Ctrl-c (^c).qwertyuiop513135
directory, run this command:php -S 0.0.0.0:80;
php -S 0.0.0.0:80;
by Ctrl-c (^c).At step 8, the user script will not match. Nothing will happen.
Response Header:
HTTP/1.1 200 OK
Date: 26 Jul 2020 02:13:11 +0800
Max-Age: 0
At step 12, the user script will match. The webpage will be redirected to google.com
.
Turn off the user script and reload the page to see the response header.
Response Header:
HTTP/1.1 200 OK
Date: Sat, 25 Jul 2020 18:15:06 GMT
Content-Length: 15
Host: localhost
Connection: close
Content-Type: text/html; charset=UTF-8
qwertyuiop513135
directory, run these 2 commands:cd ..;
rm -rf qwertyuiop513135;
I'm trying to get my script to run once all elements are loaded (including external .js scripts). I've tried event listeners and window.onload. Is there any inherent issue with asking this type of script to work inside of the extension?
Any plans to push the downloadable .app versions here?
Is there a way to synchronise Userscripts between computers? I tried a few things with aliases and symlinks but didn't succeed.
remove comments, print
s
Therefore we can use several GreasyFork scripts directly, for example, this one: https://greasyfork.org/en/scripts/37211-wikipedia-language-tabs
This bug affects the extension in both Safari 12 and 13.
If a user has set the Safari option, New windows open with:
set to Empty Page
and they open the extension before visiting a url
, the extension does not load previously saved code.
This can cause the user to believe their saved code "disappeared", when it reality it has not. In fact, the saved code executes as expected, it's just that the editor has not loaded it properly.
It seems this issue is only present when the above mentioned option is selected - with the other options or if the user navigates to a valid url after initial opening of Safari, the extension loads the code as expected.
Reproduction Steps:
New windows open with:
to the option Empty Page
It should appear as if the extension is running for the first time, as if you have no saved code, even though that is not the case.
Navigating to a website and then right clicking in the extension and selected Reload
, should get the saved code to show up properly. Also, selecting any of the other options, for the aforementioned setting or navigating to a website before opening the extension, will prevent this issue.
System Information:
macOS version 10.15.5(19F101)
userscripts version 2.0.0
Safari version 13.1.1(15609.2.9.1.2)
I saw an iChat symbolic link under:
~/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/
linked to:
../../../../../Documents/iChats
I just want to ask if this symbolic link is created by the extension or myself?
I suspect this is some weird files committed along with the app.
My computer is quite new so the iChat.app never existed on my computer.
The user should be able to "turn off" code injection - effectively bypassing the scripts in the editor.
I assume it would work something like this:
UserDefaults
or something similarUserDefaults
UserDefaults
off
, send back message stating script injection if turned off (as a console.log
message)The loadSavedData() function should run when the browser is started, not just when the view is loaded.
@include
an alias for @match
@exclude
an alias for @exclude-match
Notes:
@include
and @exclude
traditionally support regex expressions for matching and excluding, unsure if this will be implemented right now or just use them both as pure aliases to the@match
and @exclude-match
How can I install scripts from greasyfork
When pasting code that exceeds the width of the editor space, "weirdness" occurs within the editor and makes the the sidebar smaller.
I love this extension, because I primarily use safari as my browser. I had been using Tampermonkey on brave for a while just because I had to cough up two dollars if I wanted to get it on safari, so I found this and I love it! It has a great GUI and mostly works great. I have never run into an issue with it before this. I have a script that I run every once in a while on a game that I play.
let t = 3;
let b = 0;
GameManager.game.currentScene.__proto__.allowUpdate=!0,GameManager.game.currentScene.__proto__.update=function(){this.allowUpdate&&(!this.state.paused&&this.state.playing&&(this.message.update(),this.updatePlayers(),this.score.update(),this.playerManager.firstPlayer.complete?this.trackComplete():this.ticks++),this.sound.update(),this.restartTrack&&this.restart(),this.vehicleTimer.update(),this.camera.update(),this.camera.updateZoom(),this.state.showDialog||(this.updateGamepads(),this.checkGamepads())),this.updateToolHandler(),this.mouse.update(),this.screen.update(),this.updateControls(),(this.importCode||this.clear)&&this.createTrack(),this.isStateDirty()&&this.updateState(),this.stage.clear(),this.draw(),this.stage.update(),this.allowUpdate=b%t==0,b++,b%=t}
This works perfectly fine if I just paste it into the safari console, but if I try to use it as pasted there in the extension, it doesn't run. Like I said, this is the first issue I have run into with this extension. I have tried commenting out and even removing the rest of the functions I have in it, but it still doesn't work. The site that this is supposed to run on is https://freeriderhd.com/random/track . Thanks for any help!
This question gets asked a lot around here, so I've decided to make a clear issue about it and leave it open.
Currently, this extension can support some userscripts that use the Greasemonkey API, but it will likely take work from the user to get these scripts to run properly.
This extension does not support GM metadata or GM methods.
Implementing support for this is being seriously considered, along with a host of other feature requests.
Popovers with webviews don't respect the css values for cursor
- super annoying and breaks ux.
This bug was verified by Apple. I will create a workaround until Apple fixes this.
When the user clicks the toolbar button:
Certain websites with strict content security policies will not allow the injected script to run.
console error:
Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy
This will likely be the case for any website with strict policies but here are some examples:
The major issue here is that unlike legacy versions of Safari extension, this extension is not dynamically creating content scripts, that does not seem possible any more. Rather it is saving the javascript locally, then injecting it into the webpage, and immediately executing it.
It will have to investigated whether or not there is a better way to inject the script and execute the code to circumvent the CSP (I don't like this idea) or to figure out whether or not content scripts in this new format can be dynamic.
System Information:
macOS version 10.15.6(19G73)
userscripts version 2.0.0
Safari version 13.1.2(15609.3.5.1.3)
Here is a popup AD website that redirects you to another AD that buy AD service from them.
( WARNING: Usually a World of Warships AD, but sometimes NSFW ones. )
I wrote a simple script that
I try to match the above url with @match *://wadiryphi.*/*
as well as @match *://*.wadiryphi.*/*
.
But for some reason it did not work.
It worked properly if I use the JS console and run
window.location.assign('<the_url>')
But it did not work when it is opened as a link or typed into the URL text-box in Safari.
Or is this falling out of the use case of this application?
I know there are better way in doing this such as filtering at router,
or filtering by editing /etc/hosts
, but I do not want to do these.
In this way a script can be more easily imported into Chrome or other browsers
Hi, worked flawlessly with 1.5 but now it doesnt anymore.
Here is the code:
// ==UserScript==
// @name BetterTTV
// @namespace BTTV
// @description Enhances Twitch with new features, emotes, and more.
// @copyright NightDev, LLC
// @icon https://cdn.betterttv.net/assets/logos/bttv_logo.png
//
// @grant none
//
// @include *://*.twitch.tv/*
//
// @version 0.0.2
// ==/UserScript==
(function betterttv() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdn.betterttv.net/betterttv.js';
var head = document.getElementsByTagName('head')[0];
if (!head) return;
head.appendChild(script);
})()
hopefully you have some insight, i was only using userscripts for this! Thanks a lot!
Do this in the Info.plist
file
An odd example perhaps but it's the only one I can replicate the issue with.
The FrankerFaceZ extension for Twitch.tv doesn't appear to load at all in Userscripts 2.0.0 where it worked fine in the previous version. Installing InjectJS shows it working there as well.
Script is hosted at: https://cdn.frankerfacez.com/static/ffz_injector.user.js
With InjectJS the script's invoke will be reported in the Safari console. Nothing with Userscripts 2.0.0.
Hello, first congrats on the update, the intention behind it is good and will make it more powerful than the previous one. However for now, it isn't working for me as it doesn't inject anything. I've tried with several scripts and none work (while they work without issues on other browsers and extensions including the old version of yours).
I added the scripts by using the toolbar button, then +, then pasted my script, then saved > nothing. I disabled and enabled > nothing. I closed Safari and reopened it > nothing. I tried to change the metadata > nothing. I tried to open the app outside of Safari (it was no use)
I'm using Safari version 13.1.1 (15609.2.9.1.2) on 10.15.5 if that helps.
v1 pass review, here's why:
Design Preamble
The user interface of your app is not consistent with the macOS Human Interface Guidelines.
Specifically, we found that when the user closes the main application window there is no menu item to re-open it.
Next Steps
It would be appropriate for the app to implement a Window menu that lists the main window so it can be reopened, or provide similar functionality in another menu item. macOS Human Interface Guidelines state that "The menu bar [a]lways contains [a] Window menu".
Alternatively, if the application is a single-window app, it might be appropriate to save data and quit the app when the main window is closed.
For information on managing windows in macOS, please review the following sections in Apple Human Interface Guidelines:
- The Menu Bar and Its Menus
- The Window Menu
- The File Menu
- Clicking in the Dock
- Window Behavior
Please evaluate how you can implement the appropriate changes, and resubmit your app for review.
It's been a while since I've updated this extension and wanted to give an update to anyone interested.
In the months since the last update, more established and feature rich userscript extensions have come to the app store. I thought a lot about what to do next with this extension and if I should put time into creating a new update.
Even though I don't imagine this extension will ever have the same amount of features as the more established userscript managers (nor do I think I want that), I decided I would address some specific pain points I, and others, have with the version 1.x.x.
I've been slowly developing version 2 since I made that decision. The biggest pain point I've heard from users (and experienced myself) is the lack of support for multiple, domain specific userscripts. I am am addressing this and some other things with a version 2 update.
I am hoping to push the version 2 update in the near future (~ 1-2 months). If anyone is interested in beta testing, please let me know in this issue.
I will not be abandoning version 1.x.x. When version 2 comes out, I will be pushing version 1.x.x to the app store as a new/separate app under a new name (TBD). I am doing this because I have heard from some users that they do not need nor want more advanced userscript functionality.
Below you can check out a screenshot of the current build I've been testing on my machine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.