Last active
April 28, 2016 14:07
-
-
Save piotrek-k/0be47c4bf035e948d7c0 to your computer and use it in GitHub Desktop.
Tampermonkey script for modifying www pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Jedyny, niepowtarzalny, niezawodny zmieniacz zawartosci strony www | |
// @version 0.1 | |
// @description Zaprojektowany do siania dezinformacji | |
// @include * | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
var dane = {}; | |
/* | |
* ISTRUKCJE DLA SKRYPTU | |
*/ | |
dane["http://www.onet.pl"] = { //dokładny adres zmienianej strony | |
naglowki: [ | |
//w nawiasach klamrowych deklarujemy nowy obiekt do zmiany. Ilość obiektów niograniczona | |
{ | |
adresObiektuZTekstem: ".title", //selector do obiektu z tesktem ktory chcemy zmienic | |
tekstDoZmiany: "No elo ziomale", //tekst ktory chcemy wstawic zamiast tego co jest aktualnie | |
selectorDoObrazka: "#bestOfOnet > article > div > a > span.imageContainer.imgSizeBestTop > span.itemCollage.cl-1.lastCorrect > img", //sciezka do obrazka | |
urlNowegoObrazka: "http://h-o-r-s-e-s.blog.onet.pl/wp-content/blogs.dir/1233978/files/blog_ce_4690763_7131317_tr_smiesznekon.jpg", //sciezka do obrazka ktory chcemy wstawic zamiast istniejacego | |
selectorDoLinka: "#bestOfOnet > article > div > a", //selector do obiektu będącego linkiem | |
nowyLink: "http://google.com", //nowy link | |
}, | |
{ | |
adresObiektuZTekstem: "a.sliderItem:nth-child(2) > span:nth-child(2) > span:nth-child(1)", | |
tekstDoZmiany: "Test", | |
selectorDoObrazka: "a.sliderItem:nth-child(2) > span:nth-child(1) > span:nth-child(1) > span:nth-child(1) > img:nth-child(1)", | |
urlNowegoObrazka: "http://h-o-r-s-e-s.blog.onet.pl/wp-content/blogs.dir/1233978/files/blog_ce_4690763_7131317_tr_smiesznekon.jpg", | |
selectorDoLinka: "a.sliderItem:nth-child(2)", | |
nowyLink: "http://google.com", | |
}, | |
{ | |
//itd... | |
} | |
] | |
}; | |
dane["http://www.wp.pl"] = { //inna strona ktora bedzie zmieniana | |
naglowki: [ | |
{ | |
//to samo co wyżej: adresy obiektów html i dane do podmiany | |
} | |
] | |
}; | |
/* | |
* KONIEC INSTRUKCJI DLA SKRYPTU | |
*/ | |
function change(adres){ | |
var d = dane[adres]; | |
for(var q in d.naglowki){ | |
var naglowek = d.naglowki[q]; | |
try{ | |
document.querySelectorAll(naglowek.adresObiektuZTekstem)[0].innerText = naglowek.tekstDoZmiany; | |
document.querySelectorAll(naglowek.selectorDoObrazka)[0].src = naglowek.urlNowegoObrazka+""; | |
document.querySelectorAll(naglowek.selectorDoLinka)[0].href = naglowek.nowyLink+""; | |
} | |
catch(e){ | |
//tu pojawią się ewentualne błędy, ale aktualnie nas to jebie | |
console.error(e); | |
} | |
} | |
} | |
var adres = window.location.origin; | |
change(adres); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment