Skip to content

Commit 6e2e2be

Browse files
authored
Add userscript
1 parent 1cebd9c commit 6e2e2be

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

swf2js.user.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// ==UserScript==
2+
// @name Flash Player
3+
// @namespace com.swf2js
4+
// @description Play flash (.swf) files
5+
// @homepageURL https://openuserjs.org/scripts/sjehuda/Flash_Player
6+
// @supportURL https://openuserjs.org/scripts/sjehuda/Flash_Player/issues
7+
// @updateURL https://openuserjs.org/meta/sjehuda/Flash_Player.meta.js
8+
// @copyright 2023, Schimon Jehudah (http://schimon.i2p)
9+
// @license MIT; https://opensource.org/licenses/MIT
10+
// @require https://raw.githubusercontent.com/swf2js/swf2js/4619a7e06d2863bd24ae89b11b2218f00fb32771/swf2js.js
11+
// @include *
12+
// @version 23.05
13+
// @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48dGV4dCB5PSIuOWVtIiBmb250LXNpemU9IjkwIj7imqE8L3RleHQ+PC9zdmc+Cg==
14+
// ==/UserScript==
15+
16+
for (const element of document.querySelectorAll('embed[src$=".swf"]')) {
17+
18+
let divElement = document.createElement('div');
19+
divElement.textContent = 'Play ⚡';// ▶️ Click to Play
20+
divElement.setAttribute('swf-data', element.src);
21+
divElement.style.height = element.closest('object').height;
22+
divElement.style.width = element.closest('object').width;
23+
divElement.style.fontSize = element.closest('object').height / 10;
24+
divElement.style.fontStyle = 'italic';
25+
divElement.style.display = 'table-cell';
26+
divElement.style.verticalAlign = 'middle';
27+
divElement.style.background = 'DarkRed';
28+
divElement.style.color = 'WhiteSmoke';
29+
divElement.style.textAlign = 'center';
30+
divElement.style.fontWeight = 'bold';
31+
divElement.style.userSelect = 'none';
32+
33+
divElement.addEventListener ("click", function() {
34+
swf2js.load(element.src);
35+
let swfElement = document.querySelector('div[id*="swf2js_"]:last-child');
36+
swfElement.style.height = divElement.style.height;
37+
swfElement.style.width = divElement.style.width;
38+
divElement.parentNode.replaceChild(swfElement, divElement);
39+
});
40+
41+
let orgElement = element.closest('object');
42+
insertAfter(orgElement, divElement);
43+
orgElement.remove();
44+
45+
}
46+
47+
// /questions/4793604/how-to-insert-an-element-after-another-element-in-javascript-without-using-a-lib
48+
function insertAfter(referenceNode, newNode) {
49+
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
50+
}

0 commit comments

Comments
 (0)