GithubHelp home page GithubHelp logo

Comments (15)

ssborbis avatar ssborbis commented on September 3, 2024

What is your bookmarklet code? I just tested a basic script with both the popup menu and the context menu and it seems to be working.

from contextsearch-web-ext.

runningcheese avatar runningcheese commented on September 3, 2024

javascript:outText='';for(i=0;i<document.images.length;i++){if(outText.indexOf(document.images[i].src)==-1){outText+='<tr><td><img style=max-width:800px src='+document.images[i].src+'></td><td>'+document.images[i].naturalWidth+'x'+document.images[i].naturalHeight+'</td></tr><p>'}};if(outText!=''){imgWindow=window.open('','imgWin');imgWindow.document.write('<table style=margin:auto border=1 cellpadding=10><tr><th>Image</th><th>Size</th></tr><p>'+outText+'</table><p>');imgWindow.document.close()}else{alert('No Images!')}

try this code, thanks! @ssborbis

from contextsearch-web-ext.

ssborbis avatar ssborbis commented on September 3, 2024

It's failing because of CORS. A workaround would be to open the new tab to the current location, then wipe the old HTML before writing the new HTML

outText='';
for (i=0;i<document.images.length;i++){
	if (outText.indexOf(document.images[i].src)==-1) {
		outText+='<tr><td><img style=max-width:800px src='+document.images[i].src+'></td><td>'+document.images[i].naturalWidth+'x'+document.images[i].naturalHeight+'</td></tr><p>';
	}
}
if (outText != '') {
	imgWindow=window.open(window.location.href,'imgWin');
        imgWindow.document.innerHTML = null;
	imgWindow.document.write('<table style=margin:auto border=1 cellpadding=10><tr><th>Image</th><th>Size</th></tr><p>'+outText+'</table><p>');imgWindow.document.close();
} else{
	alert('No Images!');
}

from contextsearch-web-ext.

runningcheese avatar runningcheese commented on September 3, 2024

thanks for your info,
but try this extension:https://addons.mozilla.org/en-US/firefox/addon/bookmarklets-context-menu
it works well, any alternative solution? @ssborbis

from contextsearch-web-ext.

ssborbis avatar ssborbis commented on September 3, 2024

I have a possible workaround going into the master branch if you want to test. You'll need to enable the advanced setting scriptsUseBlobs : true

from contextsearch-web-ext.

runningcheese avatar runningcheese commented on September 3, 2024

hi @ssborbis,
I just downloaded the master branch file you mentioned, and reload it from browser,
and i am sure the advanced setting scriptsUseBlobs : true is on,
but the test didn't go through on chrome.

in the end,
when will this new feature be pushed to the new version?

from contextsearch-web-ext.

ssborbis avatar ssborbis commented on September 3, 2024

It appears that the test code you provided is working in chromium without the need for the additional setting. I get the same results whether the setting is enabled or not.

Firefox, however, required the new setting enabled to avoid CORS issues. Are you testing using the code you provided to test with, or some other bookmarklet code?

from contextsearch-web-ext.

ssborbis avatar ssborbis commented on September 3, 2024

If you'd been testing with scripts that contain searchTerms, they would have been failing. Try the latest code in the master branch

from contextsearch-web-ext.

runningcheese avatar runningcheese commented on September 3, 2024

@ssborbis
Unfortunately,
The new version still not working. I tested it with the simplest code javascript:alert('hi');
I have to select text before I can run it,
what i hope for is that running it from the context menu.

from contextsearch-web-ext.

ssborbis avatar ssborbis commented on September 3, 2024

Ok, I think the failure was due to needing to select text first. The latest push has a fix for that.

(edit) I only tested using the contextual layout option. Let me know what your context menu settings are.

from contextsearch-web-ext.

runningcheese avatar runningcheese commented on September 3, 2024

@ssborbis
Finally!
It works now.
That's exactly what I hope for.
When will the new version to be released? I can't wait any longer!

from contextsearch-web-ext.

runningcheese avatar runningcheese commented on September 3, 2024

@ssborbis
A big thanks for your update!!!
In the latest version, chrome and edge are working fine,
but in firefox, some bookmarklets will only display a new tab, and the function cannot be executed.
try this code, doesn't work in firefox:

javascript:outText='';for(i=0;i<document.images.length;i++){if(outText.indexOf(document.images[i].src)==-1){outText+='<tr><td><img style=max-width:800px src='+document.images[i].src+'></td><td>'+document.images[i].naturalWidth+'x'+document.images[i].naturalHeight+'</td></tr><p>'}};if(outText!=''){imgWindow=window.open('','imgWin');imgWindow.document.write('<table style=margin:auto border=1 cellpadding=10><tr><th>Image</th><th>Size</th></tr><p>'+outText+'</table><p>');imgWindow.document.close()}else{alert('No Images!')}

from contextsearch-web-ext.

runningcheese avatar runningcheese commented on September 3, 2024

Update:
After set "scriptsUseBlobs": true, everything works fine now!

from contextsearch-web-ext.

rezad1393 avatar rezad1393 commented on September 3, 2024

is scriptsUseBlobs gonna be in a new version soon?

from contextsearch-web-ext.

rezad1393 avatar rezad1393 commented on September 3, 2024

is scriptsUseBlobs gonna be in a new version soon?

because I am trying to use this bookmarklet to load broken images:
javascript: (() => { (function()%7Bvar%20images%20%3D%20document.querySelectorAll('img')%3Bfor%20(var%20i%20%3D%200%3Bi%3C%20images.length%3Bi%2B%2B)%20%7Bif%20(images%5Bi%5D.naturalWidth%20%3D%3D%3D%200%20%7C%7C%20!images%5Bi%5D.complete)%20%7Bimages%5Bi%5D.src%20%3D%20images%5Bi%5D.src%3B%7D%7Dvar%20allEle%20%3D%20document.querySelectorAll('*')%3Bfor%20(var%20i%20%3D%200%3B%20i%3CallEle.length%3B%20i%2B%2B)%20%7Bvar%20bgimg%20%3D%20getComputedStyle(allEle%5Bi%5D).getPropertyValue('background-image').replace('url(%22'%2C'').replace('%22)'%2C'')%3Bif%20(bgimg%20!%3D%3D%20'none')%20%7BallEle%5Bi%5D.style.backgroundImage%20%3D%20'url(%22'%2B%20bgimg%20%2B'%22)'%3B%7D%7Dimages%20%3D%20%5B%5D%3BallEle%20%3D%20%5B%5D%7D)(); })();

from contextsearch-web-ext.

Related Issues (20)

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.