Skip to content
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

4.1.4 bug #651

Open
profcaju opened this issue Dec 19, 2024 · 17 comments
Open

4.1.4 bug #651

profcaju opened this issue Dec 19, 2024 · 17 comments

Comments

@profcaju
Copy link

I use this extension to "Run Javascript". It is a very powerful tool!! Love it a lot. I am really grateful for your work 🤗

Since the update to 4.1.4 today, none of my shortcuts are working anymore.

A simple test, using the code:

console.log("test");

when pressing "a" key does nothing in any website (checking the console for the output).

image

Do I have to make some changes to put it back to work?

Kind regards,

@mike2587
Copy link

I confirm the issue. No shortcuts keys are working

@Adam-Krisztian-Sandor
Copy link

Dear users!

I found a solution for me. Please follow my steps:

  1. Uninstall this extension from Google Chrome.
  2. Install this extension again.
  3. Have Fun!

@profcaju
Copy link
Author

I tried to uninstall/install again with no success.

For now, I installed version 4.1.3 that works flawlessly for me.

@hababr
Copy link
Contributor

hababr commented Dec 19, 2024

Have you enabled Developer mode on Extensions page? @profcaju @mike2587

@profcaju
Copy link
Author

Yes. Developer mode is always on.

image

@mike2587
Copy link

Same

@hababr
Copy link
Contributor

hababr commented Dec 19, 2024

I see you are using Edge, tested there - works for me. Could you try a clean profile and other browser?

@hamedhomaee
Copy link

Dear @hababr,
I am having the same issue.
This problem started after 4.1.4 update, before that I had no issue.
I am using this extension on Chrome.
I really appreciate your help and support.
Thank you.

@hababr
Copy link
Contributor

hababr commented Dec 22, 2024

@hamedhomaee Let's try to find the issue. For me 4.1.4 works in all chromium based browsers I have installed. Which shortcut 'Behaviors' do not work for you? All of them or 'Run JavaScript' only? Make sure you do not have empty shortcuts.

Please try these steps:

  1. Remove and re-install the extension
  2. Enable 'Collect errors' in the extension's 'Details'
  3. Import the shortcut I attached below, delete any empty lines, save
  4. Open any website, press a, you should get a message
  5. Go back to Extensions page and check if an Errors buttons appeared
[
  {
    "key": "a",
    "action": "javascript",
    "activeInInputs": false,
    "blacklist": false,
    "code": "alert(\"A is pressed\")",
    "id": "6f233995-c936-40fe-bfb0-a09fb65ca2a8",
    "sites": "",
    "sitesArray": [
      ""
    ]
  }
]

@hamedhomaee
Copy link

Dear @hababr,
Thank you very much for your message.
I followed your instruction and in the error page I got the following error:

(()=>{"use strict";if(void 0===e)var e=chrome;async function t(t,n){const[o]=await e.tabs.query({currentWindow:!0,active:!0});return e.scripting.executeScript({target:{tabId:o.id},func:t,args:n})}if(void 0===n)var n=chrome;async function o(e,t,o,i=0){return new Promise(((r,a)=>{try{n.debugger.sendCommand({tabId:e},t,o,(e=>setTimeout((()=>r(e)),i)))}catch(e){a(e)}}))}async function i(e,t){const n=await fetch(t),o=await n.blob(),i=document.createElement("a");i.href=URL.createObjectURL(o),i.download=e,i.click()}const r=async function({fullsize:e=!1,force:r=!1}={}){const[{id:a,url:s,height:c,width:l}]=await n.tabs.query({currentWindow:!0,active:!0});n.debugger.attach({tabId:a},"1.3",(async()=>{try{let n=c;e&&(n=r?16348:await async function(){return(await t((()=>document.body.scrollHeight)))[0]}()),await o(a,"Emulation.setDeviceMetricsOverride",{height:n,width:l,mobile:!1,deviceScaleFactor:0},200);const{data:d}=await o(a,"Page.captureScreenshot");t(i,[${new URL(s).hostname}.png,data:image/png;base64,${d}])}finally{n.debugger.detach({tabId:a})}}))};if(void 0===a)var a=chrome;let s=[void 0,void 0];a.tabs.onActivated.addListener((function(e){s=[s[1],e]})),a.windows.onFocusChanged.addListener((async function(e){if(-1===e)return;const[{id:t}]=await a.tabs.query({windowId:e,active:!0});s=[s[1],{windowId:e,tabId:t}]})),a.tabs.onRemoved.addListener((function(e){s=s.map((function(t){if(!t||t.tabId!==e)return t}))}));const c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var l,d=new Uint8Array(16);function u(){if(!l&&!(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(d)}for(var f=[],w=0;w<256;++w)f.push((w+256).toString(16).slice(1));const b=function(e,t,n){if(c.randomUUID&&!t&&!e)return c.randomUUID();var o=(e=e||{}).random||(e.rng||u)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=o[i];return t}return function(e,t=0){return(f[e[t+0]]+f[e[t+1]]+f[e[t+2]]+f[e[t+3]]+"-"+f[e[t+4]]+f[e[t+5]]+"-"+f[e[t+6]]+f[e[t+7]]+"-"+f[e[t+8]]+f[e[t+9]]+"-"+f[e[t+10]]+f[e[t+11]]+f[e[t+12]]+f[e[t+13]]+f[e[t+14]]+f[e[t+15]]).toLowerCase()}(o)};if(void 0===h)var h=chrome;let p=e=>{h.tabs.query({currentWindow:!0}).then((function(t){t.length<=1||h.tabs.query({currentWindow:!0,active:!0}).then((function(n){let o,i=n[0],r=t.findIndex((e=>e.id===i.id));switch(e){case"next":o=t[(r+1+t.length)%t.length];break;case"previous":o=t[(r-1+t.length)%t.length];break;case"first":o=t[0];break;case"last":o=t[t.length-1];break;default:let n=parseInt(e)||0;if(!(n>=1&&n<=t.length))return;o=t[n-1]}h.tabs.update(o.id,{active:!0})}))}))},m=async(e,n={})=>{var o=n.smoothScrolling?"smooth":"auto";if("cleardownloads"===e)h.browsingData.remove({since:0},{downloads:!0});else if("viewsource"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.create({url:"view-source:"+e[0].url})}));else if("print"===e)t((()=>window.print()));else if("opensettings"===e)h.tabs.create({url:"chrome://settings",active:!0});else if("openextensions"===e)h.tabs.create({url:"chrome://extensions",active:!0});else if("openshortcuts"===e)h.tabs.create({url:"chrome://extensions/shortcuts",active:!0});else if("nexttab"===e)p("next");else if("prevtab"===e)p("previous");else if("firsttab"===e)p("first");else if("lasttab"===e)p("last");else if("lastusedtab"===e)!async function(){const[e,t]=s;e&&(e.windowId!==t.windowId?await a.windows.update(e.windowId,{focused:!0}):await a.tabs.update(e.tabId,{active:!0}))}();else if("newtab"===e)h.tabs.create({});else if("reopentab"===e)h.sessions.getRecentlyClosed({maxResults:1}).then((function(e){let t=e[0];h.sessions.restore(t.sessionId)}));else if("closetab"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.remove(e[0].id)}));else if("clonetab"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.duplicate(e[0].id)}));else if("movetabtonewwindow"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.windows.create({url:e[0].url}),h.tabs.remove(e[0].id)}));else if("onlytab"===e)h.tabs.query({currentWindow:!0,pinned:!1,active:!1}).then((function(e){let t=[];e.forEach((function(e){t.push(e.id)})),h.tabs.remove(t)}));else if("closelefttabs"===e||"closerighttabs"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(t){let n=t[0].index;h.tabs.query({currentWindow:!0,pinned:!1,active:!1}).then((function(t){let o=[];t.forEach((function(t){("closelefttabs"===e&&t.index<n||"closerighttabs"===e&&t.index>n)&&o.push(t.id)})),h.tabs.remove(o)}))}));else if("togglepin"===e)h.tabs.query({active:!0,currentWindow:!0}).then((function(e){let t=!e[0].pinned;h.tabs.update(e[0].id,{pinned:t})}));else if("togglemute"===e)h.tabs.query({active:!0,currentWindow:!0}).then((function(e){let t=!e[0].mutedInfo.muted;h.tabs.update(e[0].id,{muted:t})}));else if("copyurl"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){t((e=>{const t="text/plain",n=new Blob([e],{type:t}),o=[new ClipboardItem({[t]:n})];navigator.clipboard.write(o)}),[e[0].url])}));else if("searchgoogle"===e)t((()=>window.getSelection().toString())).then((function(e){const t=e[0].result;if(t){let e=encodeURIComponent(t);h.tabs.query({currentWindow:!0,active:!0}).then((function(t){h.tabs.create({url:"https://www.google.com/search?q="+e,index:t[0].index+1})}))}}));else if("movetableft"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){e[0].index>0&&h.tabs.move(e[0].id,{index:e[0].index-1})}));else if("movetabright"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.move(e[0].id,{index:e[0].index+1})}));else if("movetabtofirst"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){e[0].index>0&&chrome.tabs.move(e[0].id,{index:0})}));else if("movetabtolast"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.move(e[0].id,{index:-1})}));else if("gototab"===e){let e=()=>{h.tabs.create({url:n.openurl})};if(n.matchurl){let t={url:n.matchurl};n.currentWindow&&(t.currentWindow=!0),h.tabs.query(t).then((function(t){t.length>0?(h.tabs.update(t[0].id,{active:!0}),h.windows.update(t[0].windowId,{focused:!0})):e()}))}else e()}else if("gototabbytitle"===e){if(n.matchtitle){let e={title:n.matchtitle};n.currentWindow&&(e.currentWindow=!0),h.tabs.query(e).then((function(e){e.length>0&&(h.tabs.update(e[0].id,{active:!0}),h.windows.update(e[0].windowId,{focused:!0}))}))}}else if("gototabbyindex"===e)n.matchindex&&p(n.matchindex);else if("newwindow"===e)h.windows.create();else if("newprivatewindow"===e)h.windows.create({incognito:!0});else if("closewindow"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.windows.remove(e[0].windowId)}));else if("fullscreen"===e)h.windows.getCurrent().then((function(e){var t="fullscreen"===e.state?"normal":"fullscreen";h.windows.update(e.id,{state:t})}));else if("zoomin"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.getZoom(e[0].id).then((function(t){h.tabs.setZoom(e[0].id,t+.1)}))}));else if("zoomout"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.getZoom(e[0].id).then((function(t){h.tabs.setZoom(e[0].id,t-.1)}))}));else if("zoomreset"===e)h.tabs.query({currentWindow:!0,active:!0}).then((function(e){h.tabs.setZoom(e[0].id,0)}));else if("showlatestdownload"===e)chrome.downloads.search({orderBy:["-startTime"],state:"complete"},(e=>{e&&e.length>0&&chrome.downloads.show(e[0].id)}));else if("back"===e)t((()=>window.history.back()));else if("forward"===e)t((()=>window.history.forward()));else if("reload"===e)t((()=>window.location.reload()));else if("hardreload"===e)h.tabs.reload({bypassCache:!0});else if("top"===e)t((e=>window.scrollTo({left:0,top:0,behavior:e})),[o]);else if("bottom"===e)t((e=>window.scrollTo({left:0,top:document.body.scrollHeight,behavior:e})),[o]);else if("scrollup"===e)t((e=>window.scrollBy({left:0,top:-50,behavior:e})),[o]);else if("scrollupmore"===e)t((e=>window.scrollBy({left:0,top:-500,behavior:e})),[o]);else if("pageup"===e)t((e=>window.scrollBy({left:0,top:-window.innerHeight,behavior:e})),[o]);else if("scrolldown"===e)t((e=>window.scrollBy({left:0,top:50,behavior:e})),[o]);else if("scrolldownmore"===e)t((e=>window.scrollBy({left:0,top:500,behavior:e})),[o]);else if("pagedown"===e)t((e=>window.scrollBy({left:0,top:window.innerHeight,behavior:e})),[o]);else if("scrollleft"===e)t((e=>window.scrollBy({left:-50,top:0,behavior:e})),[o]);else if("scrollleftmore"===e)t((e=>window.scrollBy({left:-500,top:0,behavior:e})),[o]);else if("scrollright"===e)t((e=>window.scrollBy({left:50,top:0,behavior:e})),[o]);else if("scrollrightmore"===e)t((e=>window.scrollBy({left:500,top:0,behavior:e})),[o]);else if("openbookmark"===e||"openbookmarknewtab"===e||"openbookmarkbackgroundtab"===e||"openbookmarkbackgroundtabandclose"===e)h.bookmarks.search({title:n.bookmark}).then((function(o){let i;for(let e=o.length;e-- >0;){let t=o[e];if(t.url&&t.title===n.bookmark){i=t;break}}"openbookmark"===e?0===i.url.indexOf("javascript:")?t((e=>document.dispatchEvent(new CustomEvent("shortkeys_js_run",{detail:e}))),[decodeURIComponent(i.url.replace("javascript:",""))]):h.tabs.update(null,{url:decodeURI(i.url)}):"openbookmarkbackgroundtab"===e?h.tabs.create({url:decodeURI(i.url),active:!1}):"openbookmarkbackgroundtabandclose"===e?h.tabs.create({url:decodeURI(i.url),active:!1}).then((function(e){var t=function(n,o,i){n===e.id&&"complete"===o.status&&(h.tabs.remove(e.id),h.tabs.onUpdated.removeListener(t))};h.tabs.onUpdated.addListener(t)})):h.tabs.create({url:decodeURI(i.url)})}));else if("openapp"===e)n.openappid&&h.management.launchApp(n.openappid);else if("capturescreenshot"===e)r();else if("capturefullsizescreenshot"===e)r({fullsize:!0});else{if("forcecapturefullsizescreenshot"!==e)return!1;r({fullsize:!0,force:!0})}return!0};async function g(){const e=(JSON.parse((await chrome.storage.local.get("keys")).keys)||[]).filter((e=>"javascript"===e.action)).reduce(((e,t)=>(e+=JSON.stringify(t.id)+":")+"function() {"+t.code+"},"),"{")+"}",t=await chrome.userScripts.getScripts({ids:["shortkeys-actions"]}),n=[{id:"shortkeys-actions",matches:["*://*/*"],world:"MAIN",js:[{code:const handlers = ${e};\n(${function(){document.addEventListener("shortkeys_js_run",(function(e){handlers[e.detail]&&handlerse.detail}))}.toString()})();}]}];t.length?await chrome.userScripts.update(n):await chrome.userScripts.register(n)}chrome.storage.local.onChanged.addListener(g),chrome.runtime.onInstalled.addListener((async function(e){"update"===e.reason&&(await async function(){const e=JSON.parse((await chrome.storage.local.get("keys")).keys)||[];for(const t of e)t.id||(t.id=b());await chrome.storage.local.set({keys:JSON.stringify(e)})}(),g())})),h.commands.onCommand.addListener((function(e){e=e.split("-")[1],m(e)})),h.runtime.onMessage.addListener((function(e,t,n){chrome.notifications.onButtonClicked.addListener(((e,t)=>{"settingsNotification"===e&&0===t&&chrome.runtime.openOptionsPage()}));const o=e.action;if("getKeys"===o)return(async()=>{const t=e.url,o=await chrome.storage.local.get("keys"),i={};o.keys?i.keys=JSON.parse(o.keys):chrome.notifications.create("settingsNotification",{type:"basic",iconUrl:"/images/icon_128.png",title:"Shortkeys upgraded",message:"Action needed: re-save your shortcuts to continue using them.",requireInteraction:!0,buttons:[{title:"Open and re-save settings"}]});let r=[];i.keys.length>0&&i.keys.forEach((e=>{(function(e,t){if(!e.blacklist||"false"===e.blacklist)return!0;let n=!0===e.blacklist||"true"===e.blacklist;return e.sitesArray.forEach((e=>{t.match(function(e){if(/^\/.*\/$/.test(e))return new RegExp(e.replace(/^\/(.*)\/$/,"$1"));let t=["^"];for(let n=0;n<e.length;++n){let o=e.charAt(n);"*"===o?t.push(".*"):("\\^$*+?.()|{}[]".indexOf(o)>=0&&t.push("\\"),t.push(o))}return t.push("$"),new RegExp(t.join(""))}(e))&&(n=!n)})),n})(e,t)&&r.push(e)})),n(r)})(),!0;m(o,e)}))})();

@hababr
Copy link
Contributor

hababr commented Dec 22, 2024

@hamedhomaee Not sure if the error copied correctly. Could you share a screenshot?

@hamedhomaee
Copy link

Hello @hababr,
I tried to copy and paste the error again, but it was the thing that I sent you in my previous message.
I have attached a screenshot to this message. I hope the screenshot is good enough.
I should mention that I only had "Run JavaScript" shortcuts and now I have problem with those.
Thank you.
Screenshot

@hababr
Copy link
Contributor

hababr commented Dec 22, 2024

@hamedhomaee Thank you. Please share screenshot of the settings. I want to check it looks exactly like mine.
shorcuts

@hamedhomaee
Copy link

@hababr Thanks for your reply. I have attached all the screenshots to this message, which I think might be relevant.

1 2 3

@hamedhomaee
Copy link

Dear @hababr,
I have installed the previous version of the extenion (4.1.3) from a website and installed it and now everything works perfectly.
So I believe I can say that something is wrong with the new version (4.1.4).
Thank you.

@hababr
Copy link
Contributor

hababr commented Dec 22, 2024

@hamedhomaee Does 4.1.3 work on all sites, for example mail.google.com and youtube.com?

@hamedhomaee
Copy link

Dear @hababr,
Yes. I added a simple "alert" and tried it in multiple sites "YouTube.com", "google.com", and "microsoft.com". It worked perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants