1

I'm using Greasemonkey and I was trying to write my own userscript. I've already got the code, but it's not "running", dunno why.

// ==UserScript==
// @name       Image link
// @version    0.1
// @include      http://*.*
// @run-at      document-end
// ==/UserScript==
var img = document.getElementById('image'),
style = img.currentStyle || window.getComputedStyle(img, false),
link = style.backgroundImage.slice(4, -1);
alert(link);

What can I do to make it actually work?

VixinG
  • 1,387
  • 1
  • 17
  • 31
  • what are you trying to do with your script? – Reason Jul 05 '13 at 15:04
  • I'm trying to get an image link from `` in a Pop-up alert. – VixinG Jul 05 '13 at 15:06
  • While the script is not robust, it nevertheless *does* work on *static* pages that have an `#image` node with the proper style. **How** does it not work for you? On **what page, exactly**? What's your browser version? GM version? **What does the error console say?** – Brock Adams Jul 09 '13 at 09:07
  • It had something to do with the page's script, which was blocking mine from running. Thanks, but I already threw that out ;) – VixinG Jul 10 '13 at 00:12
  • Hey, can you answer your own question (if you're still around) so this quits showing up as unanswered so I don't keep reading it every day lol – Kat Cox Oct 11 '13 at 19:15

1 Answers1

0

Code is good, but the website was broken. It works on a different one.

VixinG
  • 1,387
  • 1
  • 17
  • 31