Greasemonkey 스크립트를 사용하여 페이지의 현재 URL을 변경하고 싶습니다.GreaseMonkey를 사용하여 URL 변경
내 말은 "http://www.mywebsite.com/video/old/*.mkv"이고 나는 ""로 이동하고 싶습니다. 그래서 기본적으로 URL의 "new"에서 "old"를 변경하려고합니다.
var oldUrlPath = window.location.pathname;
/*--- Test that ".compact" is at end of URL, excepting any "hashes"
or searches.
*/
var newURL = window.location.protocol + "//"
+ window.location.host
+ oldURLPath
+ window.location.search
+ window.location.hash
;
/*-- replace() puts the good page in the history instead of the
bad page.
*/
window.location.replace (newURL);
하지만 내가 원하는 newURLPath하여 oldURLPath을 교체하는 방법을 알고 돈 :
이 나는이 코드를 발견했다. replace()를 사용해야한다고 생각합니다. 그러나 확실하지 않습니다. (모든 코드는 작동하지 않으며 ReGex에 익숙하지 않아 올바르게 사용하지 않아야합니다.)
답장을 보내 주셔서 감사합니다.
하지,하지만, ('/ old /', '/ new /')를 대체하십시오. – wOxxOm
@ w0x 글쎄, 일반적으로 또 하나의'/ old /'가있는 경우 실패 할 것이다. – nicael