Giter Club home page Giter Club logo

userscripts's People

Contributors

actcd avatar dekpient avatar dependabot[bot] avatar elyscape avatar lucka-me avatar lukereichold avatar maggch97 avatar quoid avatar spd2last avatar traderstf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

userscripts's Issues

Additional language support

Support for additional languages, firstly focusing on the following languages because I have resources for these:

  • Polish
  • Spanish
  • Swedish

Save script to plain js file

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.

Firing script on page load completion

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?

Implement Metadata Block from Greasemonkey API

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:

  • Filter websites where the script can be ran
  • Fetches any requirement (external lib)
  • Identifies script (useful when multiple scripts are managed)

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.

URL matching did not work in presence of redirection

System Information:

macOS version 10.15.6(19G73)
userscripts version 2.0.0
Safari version 13.1.2(15609.3.5.1.3)

Question regarding the URL matching mechanism

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. )

https://wadiryphi.pro/bb3cV.0dP-2fhg0hYiX_RkilPmTnE-mpcqnrJsp_ZuDv1wlxY-jzgA2BYCz_gE0FNGDHJ-kJMKWLJMi_NODPIQ4RZ-TTkU1VNWz_cY3ZYaTbU-4dOeTfdgm_OiDjMk1lM-inZoypcq3_JsjtPuWvh-pxcy3zRAv_cCnDlEiFY-WHNIrJJKn_NMJNZODP0-yRNSTTEU1_MWTXgY3ZJ-nbpcvdbem_VgJhZiDj0-ylNmTnEo1_MqTrgs3t

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.

  • I suspect that this is due to the timing when the extension code is fired, but I am not sure how to debug this.

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.

Popover doesn't respect css cursor values

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.

Catalina Popover Bug

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.

Version 2

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.

Screen Shot 2020-03-24 at 22 10 25

Refactor codebase

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.

Global variable inaccessible

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!

Per-site scripts

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?

FrankerFaceZ on Twitch not loaded in Userscripts 2.0.0, works in 1.x and InjectJS

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.

Enable script injection at first launch

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.

iPad os

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

Purge manifest of manually removed script files

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.

Download functionality improvement

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.

Make adjustments to pass App Store Review

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.

Safari Option - "New windows open with", can break extension functionality

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:

  • Have the extension installed, code saved and Safari running
  • Set the Safari settings, New windows open with: to the option Empty Page
  • Close Safari
  • Re-open Safari
  • Verify that Safari has opened to an Empty Page
  • Click the extension button

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.

Test v1.1.0

in progress

Encountered issues:

  • UserDefaults isn't created at first launch, so forced to click toggle on first use
    • options to fix:
      • change this line to != "off"
      • create UserDefaults on first launch

Editor overflow

When pasting code that exceeds the width of the editor space, "weirdness" occurs within the editor and makes the the sidebar smaller.

Enable @include and @exclude metadata fields

  • Make @include an alias for @match
  • Make @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

Reference: #45 #46 #53

[artefact] iChat.app symbolic link

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.

URL matching does not work if HTTP response's "Host" field is not correctly set by the server.

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.

Required external tools:

  • netcat (nc)
  • php

Step to reproduce:

  1. Use the extension and create a new script with these code:
// ==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')
  1. run these 3 shell commands:
mkdir qwertyuiop513135;
cd qwertyuiop513135;
echo '<html></html>\n' > test.html;
  1. Use Safari and visit http://localhost/test.html. Safari should not be able to reach to server.
  2. Open devtools
  3. At the qwertyuiop513135 directory, run this command:
nc -kl 80 < test.html;
  1. Reload page.
  2. In devtools, goto Networks tab. Click the item test.html, a panel will appear.
  3. In the panel, select Headers. Check the HTTP response.
  4. Terminate the command nc -kl 80 < test.html; by Ctrl-c (^c).
  5. At the qwertyuiop513135 directory, run this command:
php -S 0.0.0.0:80;
  1. Repeat step 6 to 8.
  2. Terminate the command php -S 0.0.0.0:80; by Ctrl-c (^c).

Observations:

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

Clean up:

  • At the qwertyuiop513135 directory, run these 2 commands:
cd ..;
rm -rf qwertyuiop513135;
  • Remove the user script named 'qwertyuiop513135'

Does this extension support GM Scripts?

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.

BTTV Userscript does not work anymore with 2.0

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!

Content Security Policies Issues

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.

Toolbar button improvements

When the user clicks the toolbar button:

  • check if there is an instance of the extension page already open, if so, go to that tab rather than opening a new instance

Userscripts Settings Not Displaying

I'm on macOS Mojave and upon clicking the Userscripts </> icon in the toolbar, I see a black screen with "Userscripts Safari" centered in the middle. I don't see any other options.

Screen Shot 2020-07-11 at 11 58 52 AM

Allow users to adjust editor options through in-editor metadata

Allows 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; */

Sync Userscripts

Is there a way to synchronise Userscripts between computers? I tried a few things with aliases and symlinks but didn't succeed.

Handle outdated browsers

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

No injection with Javascripts from OpenUserJS

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.

Fix "last edited" when no date exists

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...

On/off button

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:

  • save on/off status in UserDefaults or something similar
  • by default script injection is turned on
  • when user toggles button, update status in UserDefaults
  • when injected script requests saved code, check UserDefaults
    • if off, send back message stating script injection if turned off (as a console.log message)
  • the user can still interact with editor when script injection is turned off?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.