Skip to content

Hotfix YT Script #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1d6fecd
Add mostly local resource loading and basic react player loading
pattontim Aug 30, 2022
ac1daf6
Button and extract handlers, time bordering, debug
pattontim Aug 31, 2022
2f245cc
Update .gitignore
alexis- Sep 1, 2022
e98e448
Load YT scripts async, speed slider
pattontim Oct 3, 2022
f7abb05
Merge remote-tracking branch 'upstream/master'
pattontim Oct 3, 2022
9ab2521
Fix spurious CORS error, prep fullscreen handler
pattontim Oct 3, 2022
eb10feb
Implement basic new window timestamp syncingWIP
pattontim Nov 24, 2022
2bf9903
Add extract sync, remove unneceesary header libs
pattontim Dec 7, 2022
a1c096f
Implement extracts, window close on nav and re-open
pattontim Dec 7, 2022
ae50af7
Update readme
pattontim Dec 7, 2022
b0344b8
Add extract sync on delete, more closely sync with SM parent, add mor…
pattontim Dec 9, 2022
6840870
Rearrange UI elems, sync more elems, add arrow inputs
pattontim Dec 13, 2022
fe59925
Update yt.htm
pattontim Dec 13, 2022
86317ae
Update README.md
pattontim Dec 14, 2022
aeccb73
Update image with new UI
pattontim Dec 14, 2022
80971f1
Fix YouTube htm and extract esc
pattontim Dec 26, 2022
a1b6dc2
Add WebSocket header routing
pattontim Jan 2, 2023
ea5ca40
use simple-jrpc to handle RPC calls and register
pattontim Jan 4, 2023
5103bbc
WS Edge operates like IE player completely
pattontim Jan 6, 2023
4062585
Window close cleanly, user starts jukebox
pattontim Jan 8, 2023
eb7fb76
Make WS buttons optional
pattontim Jan 10, 2023
2dac6d5
insert start parameter
pattontim Jan 13, 2023
ffe123d
Keep history
pattontim Jan 14, 2023
0a1fd86
Seperate out script for reuse
pattontim Jan 14, 2023
0c52e45
Fix window opening
pattontim Jan 14, 2023
50fa8e2
call play/pause while extracting, add 5s extract convenience buttons
pattontim Jan 19, 2023
170bf3c
Externally loaded sync API
pattontim Jan 25, 2023
b6e2b52
More sync event routing methods and fix message invocation
pattontim Jan 30, 2023
28ba187
load SM handlers dynamically
pattontim Feb 3, 2023
d31e2d6
queue iframe state, value change handlers
pattontim Feb 6, 2023
1b18799
Add youtube video details convenience btn
pattontim May 11, 2023
82e7078
Add missing yt detail buttons
pattontim May 11, 2023
2613af0
Update README.md
pattontim Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# SuperMemoScripts
# Project Archived! Please use: https://github.com/pattontim/supermemo.js

---

---

---

Compilation of scripts for [SuperMemo](www.supermemo.wiki), submitted by users of the community.

Expand Down Expand Up @@ -39,4 +45,4 @@ Include the following elements when submitting your script:

1. Fork this repository,
2. Push changes to your fork,
3. Send a Pull Request.
3. Send a Pull Request.
82 changes: 68 additions & 14 deletions YouTubeReactExtension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ SuperMemo YouTube extract performance improvements and extensions.

## Description

Utilize a locally hosted service to remove remote requirements saving up to 500ms per card and utilize the react-player to extend the functionality of incremental video in SM-18.
Fixes SuperMemo memleaks and slowdowns with a popup window. Utilize a locally hosted service to remove remote requirements saving up to 500ms per card and utilize the react-player to extend the functionality of incremental video in SM-18. I now consider this a beta and usable, it won't overwrite your cards under expected operation. However, I recommend that you [backup your collection](https://www.supermemo.wiki/en/supermemo/backup-guide) before starting to use this extension.

![Screenshot](main-screen.png)

## Getting Started

### Dependencies

* python2 or 3
* nodejs + npm installed
* SuperMemo 18
* Windows

Expand All @@ -22,42 +23,95 @@ Utilize a locally hosted service to remove remote requirements saving up to 500m

* Open the server folder in Terminal

* [not neccessary, binaries already provided] Install the react player.

```
npm install react-player # or yarn add react-player
```

* Start the server to host resources. Uses port 8000 by default.
```
python -m SimpleHTTPServer

OR

python3 -m http.server

```

* backup YouTube.htm in your install SuperMemo/bin folder

* if above succeeds, replace YouTube.htm to your installs SuperMemo/bin folder with the one provided in this ZIP. Or simply replace:
* if above succeeds, replace YouTube.htm to your installs SuperMemo/bin folder with the one provided in this ZIP

## Help

### One of my extract timestamps wiped!?

This can rarely happen if you hold ALT+LEFT or ALT+RIGHT and cycle theough many cards quickly. You may recover the times from the title of the card.

### The Player is too small, out of place, etc..

Adjust top, left, width and height in sep_embed to adjust screen placement.

### Server errors

Instead of using the python standard server, run serveit.py instead. Use the command
```
sBaseUrl = "http://localhost:8000/yt.htm?"
python serveit.py 8000
```

## Help
### SecurityError

If you get a security error, you may need to increase the number of allowed connections in your browser. Link to a SO post for IE on how to do this for WebSockets: https://stackoverflow.com/a/56889101


### I'm not sure how to use this...

1. Download the zip off github, you'll have a SupermemoScripts zip file.
2. Unzip it and go into SuperMemoScripts/YoutubeReactExtension.
3. Copy YouTube.htm and paste it in C:/SuperMemo/bin, replacing the existing YouTube.htm.
4. Go into the server folder in SuperMemoScripts/YoutubeReactExtension.
5. Hold shift key and right click, select the menu option "open in terminal". You might have to select the more options menu for it to appear.
6. Enter python -m http.server
7. If it says Python can't be found, install python from the Microsoft store and repeat from step 5, or try "py", " python3" instead of python.
Leave the terminal open and restart from step 4. every time you use SM

### Known bugs

- Closing a player with extracts on it and using the Reopen button will result in errors when making even more extracts.

### Differences with vanilla supermemo

Not currently finished.
- Extract background colour is lost (blue)
- Clicking fields inserts current time

## Version History

* 0.1 WIP
* 0.1
* Mark/Stop/Start buttons work
* Loading YouTube videos
* Loads SM scripts locally
* 0.2
* Nonblocking player and hotkeys
* Playback speed slider
* 0.3 BETA
* Bypass MEMLEAK in supermemo
* Load external IE window with YT player
* Changes reflect back to SM
* Extracts and navigation work
* Start, Stop, Mark textbox can be clicked to set times
* Everything in the UI works
### Roadmap
* Title extract verification for timing overwrite error
* Pleasing layout
* Window fullscreen
* Serverside:
* Store playback speeds
* File-YT proxy for lightning fast plays
* More shortcuts such as fullscreen, extract setting using keys, etc...
* Visualize extracts on timeline
- Enter to OK
* SupermemoAssistant plugin to re-use player and make a YouTube Jukebox
* Browser plugin and YouTube player integration

## License

Inherits license in the root of the project.

## Acknowledgments

* [SuperMemo yt.htm](https://www.super-memory.com/)
* [SuperMemo yt.htm](https://www.super-memory.com/)
Binary file added YouTubeReactExtension/main-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 58 additions & 3 deletions YouTubeReactExtension/server/YouTube.htm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,40 @@
<input type="text" value="0:00:00" id="resumevideoat" onfocus="this.select();" ondblclick="resetAt('resume');" onchange="this.value = convertDuration2HHMMSS(convertHHMMSS2Duration(this.value));" />
<input type="text" value="0:00:00" id="startvideoat" onfocus="this.select();" onchange="this.value = convertDuration2HHMMSS(convertHHMMSS2Duration(this.value)); document.getElementById('imposeboundries').value = 0; updateBorder(this);" ondblclick="resetAt('start');" />
<input type="text" value="0:00:00" id="stopvideoat" onfocus="this.select();" onchange="this.value = convertDuration2HHMMSS(convertHHMMSS2Duration(this.value)); document.getElementById('imposeboundries').value = 0; updateBorder(this);" ondblclick="resetAt('stop');" />
<div class="ctrlGrp">
<textarea id="log" style="width: 100%"></textarea>
</div>
<script type="text/javascript">
// define a new console
var console=(function(oldCons){
var oLog = document.getElementById("log");
return {
log: function(text){
//oldCons.log(text);
oLog.innerHTML += '[LOG] ' + text + '\n';
},
info: function (text) {
//oldCons.info(text);
// Your code
oLog.innerHTML += '[INFO] ' + text + '\n';
},
warn: function (text) {
//oldCons.warn(text);
// Your code
oLog.innerHTML += '[WARN] ' + text + '\n';
//alert( '[WARN] ' + text + '\n')
},
error: function (text) {
//oldCons.error(text);
// Your code
oLog.innerHTML += '[ERROR] ' + text + '\n';
}
};
}(window.console));

//Then redefine the old console
window.console = console;

var buildUrlString = function() {
var urlString = "",
oTs = new Date(),
Expand All @@ -33,10 +66,32 @@

return urlString;
},
sBaseUrl = "http://localhost:8000/yt.htm?",
sProtocol = 'microsoft-edge',
sBaseUrl = "http://localhost:8000/yt_new.htm?",
sBaseHeaderUrl = "http://localhost:8000/yt_header.htm?",
sUrlString = buildUrlString();

document.location.href = sBaseUrl + sUrlString;

/*
* Select one of the following default behaviours
* A) Open in SM window (memory leak)
* B) Open in new IE11 window every time
* [unfinished] C) Open in Edge window
*/

/*
* A.
*/
//document.location.href = sBaseUrl + sUrlString;

/*
* B.
*/
document.location.href = sBaseHeaderUrl + sUrlString;

/*
* C.
will use window.open(sProtocol + ':' + sBaseUrl + sUrlString;
*/
</script>
</body>
</html>
Loading