Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Changing websites yourself.

  1. Mar 27, 2005 #1
    Is it possible to replace, lets say, some of the physicsforums icons with my own? Maybe have pf look at cache first, and then replace the images with my own?

    I guess I know it is possible, just is it easy to do? Danke.
     
  2. jcsd
  3. Mar 27, 2005 #2
    Phew! are you sure You wanna do it!! I mean.. PF is not gonna give u access for that!!
     
  4. Mar 27, 2005 #3
    Well, you could like redirect all requests to https://www.physicsforums.com/images/ [Broken] to 127.0.0.1 (localhost), by editing the hosts file, set up a webserver on your own computer, download all images from PF and replace whatever ones you want to replace. More like a waste of cpu and memory if you ask me.
     
    Last edited by a moderator: May 2, 2017
  5. Mar 27, 2005 #4
    el-half gave what I think would be the easiest way. However still seems like a pain for little gain. Our graphics aren't that bad are they? :tongue2:
     
    Last edited: Mar 27, 2005
  6. Mar 27, 2005 #5
    Hmm looks like a pain I guess.

    The graphics are not bad, I have gotten used to them, but I of course would like to be able to change them, or anything, to how I want it to look.

    edit...
    One of the ways I was thinking was to have the website code downloaded, then edit all instances, of say http://www.website.com/images/image.gif [Broken] to file:///home/matt/images/image.gif
     
    Last edited by a moderator: May 2, 2017
  7. Mar 27, 2005 #6
    I think you can change websites with firefox.
     
  8. Mar 27, 2005 #7
    I was thinking about that too. But I only know how to remove objects with firefox, not change or add, gonna do a quick search and see what comes up. Do you have any more info about that?
     
  9. Mar 27, 2005 #8

    dduardo

    User Avatar
    Staff Emeritus

    I know there is a firefox extension that does this. I read about it not too long ago. I'll have to look it up.

    [edit] I found it!!

    http://greasemonkey.mozdev.org/
     
    Last edited: Mar 27, 2005
  10. Mar 27, 2005 #9
    Thanks dduardo, checking it right now :smile:

    edit... Wow! That extension is awesome! I have not changed any images on sites yet, but they have some really cool, and useful, scripts!
     
    Last edited: Mar 27, 2005
  11. Mar 27, 2005 #10
    Ok I can change images, but I only know how to change ones that have an id. How do I select an image that just has a source?

    I used this to change images with an id, but many sites do not have ids for their images, any ideas?

    Code (Text):
    (function() {
    document.getElementById('ID of image').src="location of image"
    })();
     
  12. Mar 27, 2005 #11

    dduardo

    User Avatar
    Staff Emeritus

    Your making it more difficult than it has to be. You can do something like this:

    Code (Text):

    ChangeReplyButtons() {
    for (var i=0; i < document.images.length; i++) {
    if(document.images[i].src=="images/buttons/reply.gif") {
    document.images[i].src="/home/david/myreply.gif" ;
    }}}
     
    You can add more if statements to change all the buttons. Isn't Javascript/DOM nice. I suggest you use the DOM inspector that comes with Firefox to help you.
     
    Last edited: Mar 27, 2005
  13. Mar 27, 2005 #12
    Thanks. I have the dom inspector installed, I guess the next step is to learn how to use it :smile:

    Also, I am assuming from your response that I do not have to enter "file:///" before "home."
     
  14. Mar 27, 2005 #13

    dduardo

    User Avatar
    Staff Emeritus

    You may or may not have to put file:///blah/blah/blah. When I type /home/dduardo into the browser it automatically resolves to file:///home/dduardo. Try it and see. Also remember that i'm on a linux system so on windows I don't know how this would work.
     
  15. Mar 27, 2005 #14
    Well I am on linux too :smile:

    It does not when I enter a specific location of an image that has dashes in the name, it may be something else.

    edit... and it does not seem to be working :yuck:

    This is mines.user.js
    Code (Text):

    ChangeMinesweeperPics() {
    for (var i=0; i < document.images.length; i++) {
    if(document.images[i].src=="file:///home/matt/minesweeper-beg-5.png") {
    document.images[i].src="file:///home/matt/minesweeper-int-33.png" ;
    }}}
     
    This is minetest.html
    Code (Text):

    <html>
    <title>testing</title>
    <head>
    </head>
    <body>
    <img src="file:///home/matt/minesweeper-beg-5.png" />
    </body>
     
     
    Last edited: Mar 27, 2005
  16. Mar 27, 2005 #15
    It may be me, not even my yahoo script is working now :mad:
     
  17. Mar 27, 2005 #16

    dduardo

    User Avatar
    Staff Emeritus

    I just created a simple script that replaces an image and it works just fine. Here is my code:

    test.user.js
    Code (Text):

    for (var i=0; i < document.images.length; i++) {
    if(document.images[i].src=="file:///home/dduardo/flowchart.bmp") {
    document.images[i].src="sales_tax.png" ;
    }}
     
    test.html
    Code (Text):

    <html>
    <body>
    <img src="flowchart.bmp">
    <img src="sales_tax.png">
    </body>
    </html>
     
    [edit]Actually, I just realized why your script doesn't work. Your just declaring the function but not actually running it. :rofl: :rofl:
     
  18. Mar 27, 2005 #17
    ROFL. You were right, it works now. Thanks
     
  19. Mar 27, 2005 #18
  20. Mar 27, 2005 #19
    Ok I am beginning to think that this will not work. I am only able to replace the images with other images on the pf website.
     
  21. Mar 28, 2005 #20

    dduardo

    User Avatar
    Staff Emeritus

    Are you sure?
     
  22. Mar 28, 2005 #21
    I am never sure :smile: But I have not been able to get it to work with images from other websites, or images from my computer.
     
  23. Mar 28, 2005 #22

    dduardo

    User Avatar
    Staff Emeritus

    I found the problem:

    For security reasons, Mozilla does not allow web content to link to local files. An error like:Security Error: Content at url may not load or link to file:///something will appear in the javascript console. If you need to follow links to local paths it is recommended that you drag the link to the location bar and then drop it on the webpage. If you really don't like the security check and are willing to risk all files on your system and that your system can access then you may add the following line to user.js in your personal profile directory. user_pref("security.checkloaduri", false); (Bug 84128)

    You can change the image with one on the net.
     

    Attached Files:

    Last edited: Mar 28, 2005
  24. Mar 28, 2005 #23

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You could also use PF's RSS feed, along with a webserver, to generate pages that look like anything in the world, but contain content from PF.

    - Warren
     
  25. Mar 28, 2005 #24

    dduardo

    User Avatar
    Staff Emeritus

    Huh, why I be darned, there is an RSS feed. The button is so small you wouldn't even know it was there.

    If you wanted to go down this route you could write a really simple python script that uses libxml2 and libxslt to generate a xhtml file based on the xml file you get from this site and your own xsl (xml stylesheet) file. Of course you'll need a running apache server.

    [edit] Actually it looks like the RSS feed is broken. Firefox is complaining that it isn't vaild xml.
     
    Last edited: Mar 28, 2005
  26. Mar 28, 2005 #25

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Yeah it seems like RSS is temporarily broken. I've told Greg about it -- I dunno what the deal might be. We'll get it back up soon.

    I personally think using the RSS/XML feed is the simplest and best way to do it.

    - Warren
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook