From 96fa1502bab39cb9fc3e84ac41e3c0e3e81fb0e0 Mon Sep 17 00:00:00 2001 From: Flex Date: Mon, 21 May 2018 11:02:05 -0600 Subject: [PATCH] update and add new plugins --- plugins/dblclickedit.js | 2 +- plugins/fixmentions.js | 17 ++++---- plugins/glsandbox.js | 97 +++++++++++++++++++++++++++++++++++++++++ plugins/imgxis.js | 10 ++--- plugins/localstorage.js | 8 ++-- plugins/osutyping.js | 6 +-- plugins/sailboat.js | 18 ++++---- plugins/settingsapi.js | 71 +++++++++++++++++++++++------- plugins/silenttyping.js | 20 +++++++++ plugins/spotifyspoof.js | 8 ++-- 10 files changed, 207 insertions(+), 50 deletions(-) create mode 100644 plugins/glsandbox.js create mode 100644 plugins/silenttyping.js diff --git a/plugins/dblclickedit.js b/plugins/dblclickedit.js index ed3ae47..1f382f8 100644 --- a/plugins/dblclickedit.js +++ b/plugins/dblclickedit.js @@ -6,7 +6,7 @@ exports.manifest = { exports.start = function(){ document.addEventListener("dblclick", ev => { let target = ev.target; - if(target.className.includes("markup")) { + if(target && target.className && target.className.includes("markup")) { let msg = target; let opt = msg.parentNode.querySelector(".btn-option"); opt.click(); diff --git a/plugins/fixmentions.js b/plugins/fixmentions.js index fe1da46..8f7b3b8 100644 --- a/plugins/fixmentions.js +++ b/plugins/fixmentions.js @@ -1,13 +1,14 @@ -exportsexports = { +exports = { manifest: { author: "Cynosphere, Adryd", name: "Mentions Fixer", - description: "See hidden channel mentions and remove #deleted-channel." + description: "See hidden channel mentions and remove #deleted-channel.", + replacements: [ + {signature:'/t\\.type===(.+)\\.ChannelTypes\\.GUILD_TEXT&&(.+)\\.default\\.can\\((.+)\\.Permissions\\.VIEW_CHANNEL,n,t\\)/',payload:'true'}, + {signature:/"#deleted-channel"/g,payload:'"<#"+e[1]+">"'}, + {signature:'/"@deleted-role"/',payload:'"<@&"+e[1]+">"'}, + {signature:'/guildId:null!=t\\?t\\.guild_id:null,/',payload:'guildId:null!=t.guild_id?t.guild_id:"@me",'} + ] }, - replacements: { - '/t\\.type===(.+)\\.ChannelTypes\\.GUILD_TEXT&&(.+)\\.default\\.can\\((.+)\\.Permissions\\.VIEW_CHANNEL,n,t\\)/':'true', - '/"#deleted-channel"/':'"<#"+e[1]+">"', - '/"@deleted-role"/':'"<@&"+e[1]+">"', - '/guildId:null!=t\\?t\\.guild_id:null,/':'guildId:null!=t.guild_id?t.guild_id:"@me",' - } + } \ No newline at end of file diff --git a/plugins/glsandbox.js b/plugins/glsandbox.js new file mode 100644 index 0000000..8042b29 --- /dev/null +++ b/plugins/glsandbox.js @@ -0,0 +1,97 @@ +shwatcher = null, shtag = null, setupShaders = function (n) { + var e = fs.readFileSync(n, "utf-8"); + null === shtag && (shtag = document.createElement("script").modify(x=>x.type ="x-shader/x-vertex").withId('shaderCode'), document.head.appendChild(shtag)), shtag.innerHTML = e, null === shwatcher && (shwatcher = fs.watch(n, { + encoding: "utf-8" + }, function (e, w) { + if ("change" === e) { + var i = fs.readFileSync(n, "utf-8"); + shtag.innerHTML = i + compile(); + } + })) +}; + +exports = { + manifest: { + author: "Cynosphere", + name: "GLSandboxBG", + description: "GL shaders as a background", + }, + start: function(){ + createElement('script') + .modify(x=>{ + x.type = 'text/javascript'; + x.src = 'https://rawgit.com/Cynosphere/42aec2ef76646dc52cff435cc5447f48/raw/36c3c45abee126f8550d3f3fc039b3136ab92c90/glsandbox.js?_='+Date.now(); + }) + .appendTo(document.head); + + createElement('script') + .withId('surfaceVertexShader') + .modify(x=>x.type = 'x-shader/x-vertex') + .withContents(`attribute vec3 position; +attribute vec2 surfacePosAttrib; +varying vec2 surfacePosition; + +void main() { + surfacePosition = surfacePosAttrib; + gl_Position = vec4( position, 1.0 ); +}`) + .appendTo(document.head); + + createElement('script') + .withId('fragmentShader') + .modify(x=>x.type = 'x-shader/x-vertex') + .withContents(`#ifdef GL_ES +precision mediump float; +#endif + +uniform vec2 resolution; +uniform sampler2D texture; + +void main() { + vec2 uv = gl_FragCoord.xy / resolution.xy; + gl_FragColor = texture2D( texture, uv ); +}`) + .appendTo(document.head); + + createElement('script') + .withId('vertexShader') + .modify(x=>x.type = 'x-shader/x-vertex') + .withContents(`attribute vec3 position; + +void main() { + gl_Position = vec4( position, 1.0 ); +}`) + .appendTo(document.head); + + createElement('canvas') + .withId("glsandbox") + .modify(x=>{ + x.style.height = "100%"; + x.style.width = "100%"; + x.style.top = 0; + x.style.left = 0; + x.style.position = "absolute"; + x.style["z-index"] = 0; + }) + .appendTo($('[class^="app-"]')); + + $(".app").modify(x=>x.style['z-index']=1); + + if(!$api.localStorage.get('glsbbg_firstrun')){ + console.log("%c[GLSandboxBG] ","font-weight:bold;background: linear-gradient(to bottom right, #c080ff, #ff80c0);-webkit-background-clip: text;-webkit-text-fill-color: transparent;",`To edit the shader, edit the file located in \`${$api.data}shader.frag\``); + console.log("%c[GLSandboxBG] ","font-weight:bold;background: linear-gradient(to bottom right, #c080ff, #ff80c0);-webkit-background-clip: text;-webkit-text-fill-color: transparent;","If the file doesn't exist, just create it."); + $api.localStorage.set('glsbbg_firstrun',true); + } + + if (fs.existsSync($api.data + 'shader.frag')) + setupShaders($api.data + 'shader.frag'); + + document.addEventListener("ep-ready",_=>{ + setTimeout(_=>{ + initGLSB(); + if (gl) animate(); + },500); + }); + } +} \ No newline at end of file diff --git a/plugins/imgxis.js b/plugins/imgxis.js index b830e98..fa4bf59 100644 --- a/plugins/imgxis.js +++ b/plugins/imgxis.js @@ -91,9 +91,7 @@ exports.start = function(){ function onImageOpen(element) { let wrap = document.querySelector('div[class*="imageWrapper-"]'); - const openOrig = document.querySelectorAll( - 'div a[class^="downloadLink-"]' - )[0]; + const openOrig = document.querySelectorAll('div a[class*="downloadLink-"]')[0]; openOrig.style.display = "none"; const origLink = openOrig.getAttribute("href"); var menuColors = 10; // how many color buttons to show in the menu @@ -142,11 +140,11 @@ exports.start = function(){ function fixElem(elemToFix) { if (electron.process.platform == "win32" || electron.process.platform == "darwin") { menu.style.zIndex = 3003; - menu.style.top = "22px"; + menu.style.top = $('[class*="typeWindows-"]').clientHeight+"px"; menu.style.position = "absolute"; menu.style.left = 0; - elemToFix.style.top = "22px"; - elemToFix.style.height = "calc(100vh - 22px)"; + elemToFix.style.top = $('[class*="typeWindows-"]').clientHeight+"px"; + elemToFix.style.height = `calc(100vh - ${$('[class*="typeWindows-"]').clientHeight}px)`; } else { elemToFix.style.height = "100vh"; elemToFix.style.top = 0; diff --git a/plugins/localstorage.js b/plugins/localstorage.js index e8026ac..04655a5 100644 --- a/plugins/localstorage.js +++ b/plugins/localstorage.js @@ -2,9 +2,9 @@ exports = { manifest: { author: "Cynosphere", name: "Restore Local Storage", - description: "Restore window.localStorage." - }, - replacements: { - 'try{delete window.localStorage}catch(e){}':'' + description: "Restore window.localStorage.", + replacements: [ + {signature:'try{delete window.localStorage}catch(e){}',payload:''} + ] } } \ No newline at end of file diff --git a/plugins/osutyping.js b/plugins/osutyping.js index 80723f9..329ea21 100644 --- a/plugins/osutyping.js +++ b/plugins/osutyping.js @@ -1,4 +1,4 @@ -exportsexports = { +exports = { manifest: { author: "Cynosphere, janeptrv", name: "osu! Typing", @@ -7,9 +7,9 @@ exportsexports = { start: function(){ var sounds = []; for (var i = 1; i < 4; i++) { - sounds.push(new Audio(`https://github.com/janeptrv/sounds/blob/master/osu_typing_click${i}.wav?raw=true`)); + sounds.push(new Audio(`https://raw.githubusercontent.com/janeptrv/sounds/master/osu_typing_click${i}.wav`)); } - const backspace = new Audio("https://github.com/janeptrv/sounds/blob/master/osu_typing_erase.wav?raw=true"); + const backspace = new Audio("https://raw.githubusercontent.com/janeptrv/sounds/master/osu_typing_erase.wav"); var keys = {}; function typingSound(ev) { diff --git a/plugins/sailboat.js b/plugins/sailboat.js index 7ef72f2..0570265 100644 --- a/plugins/sailboat.js +++ b/plugins/sailboat.js @@ -1,13 +1,13 @@ exports.manifest = { author: "Adryd, BlockBuilder57, Cynosphere", name: "Sailboat", - description: "Login as bot accounts." -} -exports.replacements = { - '/i.default.Store.pauseEmittingChanges\\(\\),t.user.bot/':'false', - '/.\\._reset\\(!0,1e3,"Disconnect requested by user"\\)/':'console.log("delightfully devilish seymour")', - '/\\.experiments;v={},t\\.forEach/':'.experiments;if(t==undefined) return;v={},t.forEach', - '/CONNECTION_OPEN:function\\(e\\){f=e\\.connected/':'CONNECTION_OPEN:function(e){if(e.connectedAccounts==undefined) return; f=e.connected', - '/function S\\(e\\){var t=arguments/':'function S(e){if(e==undefined) return; var t=arguments', - 'totalUnavailableGuilds,n=[];':'totalUnavailableGuilds,n=[];if(e.readState==undefined) return;' + description: "Login as bot accounts.", + replacements = [ + {signature:'/i.default.Store.pauseEmittingChanges\\(\\),t.user.bot/',payload:'false'}, + {signature:'/.\\._reset\\(!0,1e3,"Disconnect requested by user"\\)/',payload:'console.log("delightfully devilish seymour")'}, + {signature:'/\\.experiments;v={},t\\.forEach/',payload:'.experiments;if(t==undefined) return;v={},t.forEach'}, + {signature:'/CONNECTION_OPEN:function\\(e\\){f=e\\.connected/',payload:'CONNECTION_OPEN:function(e){if(e.connectedAccounts==undefined) return; f=e.connected'}, + {signature:'/function S\\(e\\){var t=arguments/',payload:'function S(e){if(e==undefined) return; var t=arguments'}, + {signature:'totalUnavailableGuilds,n=[];',payload:'totalUnavailableGuilds,n=[];if(e.readState==undefined) return;'} + ] } \ No newline at end of file diff --git a/plugins/settingsapi.js b/plugins/settingsapi.js index af99e61..0eaca5a 100644 --- a/plugins/settingsapi.js +++ b/plugins/settingsapi.js @@ -28,10 +28,10 @@ exports = { manifest: { author: "Cynosphere, BlockBuilder57", name: "Settings API", - description: "Hijack the settings menu in any way you feel." - }, - replacements: { - '/function z\\(\\){return\\[{(.+)}]}/':'window.$settingsapi={sections:[{$1}]};function z(){return window.$settingsapi.sections;}', + description: "Hijack the settings menu in any way you feel.", + replacements: [ + {signature:'/function z\\(\\){return\\[{(.+)}]}/',payload:'window.$settingsapi={sections:[{$1}]};function z(){return window.$settingsapi.sections;}'} + ] }, start: function(){ var buttons = $api.util.findFuncExports('button-', 'colorBlack'); @@ -50,18 +50,26 @@ exports = { ourSections: [], _callbacks: {}, _panels: {}, - addSection: function(name,label,callback,color){ + addSection: function(name,label,color=null,callback){ let data = {}; data.section = name || `SAPI_${Math.floor(Math.random()*10000)}`; data.label = label; - data.color = color || undefined; + data.color = color; data.element = $api.util.findConstructor('FormSection', 'FormSection').FormSection; $settingsapi.ourSections.push(data); $settingsapi.sections.splice($settingsapi.sections.length-4,0,data); $settingsapi._callbacks[name] = callback; }, + addDivider: function(){ + $settingsapi.ourSections.push({section:"DIVIDER"}); + $settingsapi.sections.splice($settingsapi.sections.length-4,0,{section:"DIVIDER"}); + }, + addHeader: function(label){ + $settingsapi.ourSections.push({section:"HEADER",label:label}); + $settingsapi.sections.splice($settingsapi.sections.length-4,0,{section:"HEADER",label:label}); + }, exportSections: function(){ let out = ""; @@ -141,7 +149,7 @@ exports = { ) .withText(text); }, - createInput: function(v) { + createInput: function(v, p) { return createElement("input") .withClass( misc.inputDefault, @@ -149,7 +157,8 @@ exports = { misc.size16, 'epMargin' ) - .modify(x => x.value = v) + .modify(x => x.value = v ? v : "") + .modify(x => x.placeholder = p ? p : "") }, updateSwitch: function(s, w) { if (s.checked) { @@ -181,23 +190,52 @@ exports = { .modify(x => x.type = 'checkbox') .modify(x => x.checked = i) .modify(x => x.onchange = () => { - updateSwitch(s, w); + $settingsapi.elements.updateSwitch(s, w); c(s.checked); }) ) $settingsapi.elements.updateSwitch(s, w); return w; + }, + internal:{ + panels:panels, + panels2:panels2, + buttons:buttons, + checkboxes:checkboxes, + misc:misc, + misc2:misc2, + headers:headers } } } //Example settings tab - /*$settingsapi.addSection("TESTING","test owo",function(pnl){ - $settingsapi.elements.createH2("Hello World!").appendTo(pnl); - });*/ + $settingsapi.addDivider(); + $settingsapi.addHeader("Element Testing"); + $settingsapi.addSection("TESTING","Element Test Page",null,function(pnl){ + let em = $settingsapi.elements; + em.createH2("Hello World! Heading 2").appendTo(pnl); + em.createH5("Hello World! Heading 5").appendTo(pnl); + em.createButton("Button!").appendTo(pnl); + em.createWarnButton("Warning Button!").appendTo(pnl); + em.createDangerButton("Danger Button!").appendTo(pnl); + em.createInput("","Input Box!").appendTo(pnl); + em.createSwitch().appendTo(pnl); - $api.events.hook("USER_SETTINGS_MODAL_SET_SECTION", function(e){ - if ($settingsapi._panels[e.section]) $settingsapi._panels[e.section].remove(); + let v = em.createVerticalPanel().appendTo(pnl); + let h = em.createHorizontalPanel().appendTo(pnl); + + em.createH2("Vertical Panel!").appendTo(v); + em.createButton("Beep Boop").appendTo(v); + + em.createH2("Horizontal Panel!").appendTo(h); + em.createButton("Boop Beep").appendTo(h); + }); + + function setupSettings(e){ + for(let i in $settingsapi._panels){ + $settingsapi._panels[i].remove(); + } for(let i in $settingsapi.ourSections){ let data = $settingsapi.ourSections[i]; @@ -212,6 +250,9 @@ exports = { $settingsapi._callbacks[data.section]($settingsapi._panels[data.section]); } } - }); + } + + $api.events.hook("USER_SETTINGS_MODAL_SET_SECTION",setupSettings); + $api.events.hook("USER_SETTINGS_MODAL_INIT",e=>setTimeout(_=>setupSettings(e),200)); } } \ No newline at end of file diff --git a/plugins/silenttyping.js b/plugins/silenttyping.js new file mode 100644 index 0000000..6ca9bb5 --- /dev/null +++ b/plugins/silenttyping.js @@ -0,0 +1,20 @@ +window._silenttyping = false; + +exports = { + manifest: { + author:"Cynosphere", + name:"SilentTyping", + description:"Toggleable typing indicators. Toggle with Ctrl+F12", + replacements:[ + {signature:/sendTyping:function\((.)\){(.*)}/,payload:"sendTyping:function($1){if(window._silenttyping) return;$2}"} + ] + }, + start:function(){ + document.addEventListener("keydown", function(ev) { + if (ev.ctrlKey && ev.key == "F12") { + window._silenttyping = !window._silenttyping; + $api.ui.fakeMsg(`Your typing indicator is now ${window._silenttyping ? "dis" : "en"}abled`); + } + }); + } +} \ No newline at end of file diff --git a/plugins/spotifyspoof.js b/plugins/spotifyspoof.js index 4fbd472..47816fb 100644 --- a/plugins/spotifyspoof.js +++ b/plugins/spotifyspoof.js @@ -2,9 +2,9 @@ exports = { manifest: { author: "Cynosphere", name: "Spotify Premium Spoof", - description: "Spoofs premium check and allows listen along without premium." - }, - replacements: { - 'r.isPremium=n':'r.isPremium=true' + description: "Spoofs premium check and allows listen along without premium.", + replacements: [ + {signature:'r.isPremium=n',payload:'r.isPremium=true'} + ] } } \ No newline at end of file