2011-12-16 28 views
0

我希望做一個書籤,將來自一個書籤使用當前URL的一部分在一個新的URL

http://user.tumblr.com/post/123456789 改變一個網頁
http://user.tumblr.com/liked/by/user

,只需點擊。我通常在frankensteining代碼好嗎在一起,我一直在尋找一個使用「window.location的」與 Bookmarklet to edit current URLReplace end characters of current URL with bookmarklet

我什麼都看不到可用沿的tumblr手動一個reblog按鈕會將一個子域提取到一個變量中,然後將其放入一個新的URL中。我沒有偶然發現這個代碼:

^http://([^.]+)\.domain\.com 

但我不知道這意味着什麼或如何使用它。

回答

0

不知道這是您尋找的,但我使用,因爲我有我的網站的多個實例和什麼書籤保持我在同一個實例,無論端口或協議。

新標籤

javascript:(function(){window.open(location.protocol+'//'+location.hostname+':'+location.port+'/liked/by/user')})(); 

當前選項卡

javascript:(function(){window.location.assign(location.protocol+'//'+location.hostname+':'+location.port+'/liked/by/user')})(); 

編輯:忘了把代碼塊

+0

工作良好,有沒有什麼辦法來檢測子域(location.subdomain沒有按」工作)並用它替換'用戶'? – user1102021 2011-12-17 23:04:00