Last active
February 12, 2018 05:46
-
-
Save dannvix/d2d5f8e0b7daa2635254 to your computer and use it in GitHub Desktop.
Revisions
-
dannvix revised this gist
Jul 21, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -98,7 +98,7 @@ var preserveScrollPositionAfterSyncUp = function() { ,' var origSyncCallback = queue.syncCallback;' ,' var lastScrollY = 0;' ,' queue.syncCallback = function() {' ,' lastScrollY = window.scrollY;' ,' origSyncCallback.apply(this, arguments);' ,' window.scrollTo(window.scrollX, lastScrollY);' ,' };' -
dannvix revised this gist
Jul 21, 2016 . 1 changed file with 6 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.9.1 // @include http://getpocket.com/* // @include https://getpocket.com/* // @@ -91,29 +91,14 @@ var hideLiveChatButton = function() { }; var preserveScrollPositionAfterSyncUp = function() { // hook and `queue.syncCallback` via injected script var script = document.createElement('script'); script.text = ['(function() {' ,' var origSyncCallback = queue.syncCallback;' ,' var lastScrollY = 0;' ,' queue.syncCallback = function() {' ,' lastScrollY = window.scrollY; ,' origSyncCallback.apply(this, arguments);' ,' window.scrollTo(window.scrollX, lastScrollY);' ,' };' @@ -127,6 +112,5 @@ if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addCustomizationIndicator, false); window.addEventListener('load', hideAllShareButtons, false); window.addEventListener('load', hideLiveChatButton, false); window.addEventListener('load', preserveScrollPositionAfterSyncUp, false); } -
dannvix revised this gist
Jul 14, 2016 . 1 changed file with 35 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,11 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.9 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.9 restore scroll position after item synchronization // @history 1.8 remove "utm_xxx=yyy" from URL parameters // @history 1.7 fix original link parsing // @history 1.6 disable automatic item synchronization @@ -33,9 +34,12 @@ var switchToOriginalLinks = function() { // unbind click event handler to prevent batch selection // since we cannot access jQuery here, we use this tricky hack var script = document.createElement('script'); script.text = ['(function() {' ,' jQuery(".item").off("click");' ,' jQuery(".item_link").off("click");' ,' jQuery(".item_content").off("click");' ,'})();' ].join('\n'); document.body.appendChild(script); }; @@ -71,19 +75,22 @@ var addCustomizationIndicator = function() { document.body.appendChild(indicator); }; var hideAllShareButtons = function() { var style = document.createElement('style'); style.textContent = 'li.action_share { display: none; }'; document.head.appendChild(style); }; var hideLiveChatButton = function() { var chatBtn = document.querySelector('#livechat-compact-container'); if (chatBtn) { document.body.removeChild(chatBtn); } }; var disableItemSynchronization = function() { var delaySecs = 1; setTimeout(function() { @@ -94,9 +101,32 @@ var disableItemSynchronization = function() { }, delaySecs * 1000/*ms*/); }; var restoreScrollPositionAfterSyncUp = function() { // hook `queue.sync` and `queue.syncCallback` via injected script var script = document.createElement('script'); script.text = ['(function() {' ,' var origSync = queue.sync,' ,' origSyncCallback = queue.syncCallback;' ,' var lastScrollY = 0;' ,' queue.sync = function() {' ,' lastScrollY = window.scrollY;' ,' origSync.apply(this, arguments);' ,' };' ,' queue.syncCallback = function() {' ,' origSyncCallback.apply(this, arguments);' ,' window.scrollTo(window.scrollX, lastScrollY);' ,' };' ,'})();' ].join('\n'); document.body.appendChild(script); }; if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addCustomizationIndicator, false); window.addEventListener('load', hideAllShareButtons, false); window.addEventListener('load', hideLiveChatButton, false); // window.addEventListener('load', disableItemSynchronization, false); window.addEventListener('load', restoreScrollPositionAfterSyncUp, false); } -
dannvix revised this gist
Jul 12, 2016 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,11 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.8 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.8 remove "utm_xxx=yyy" from URL parameters // @history 1.7 fix original link parsing // @history 1.6 disable automatic item synchronization // @history 1.5 hide the live chat button @@ -24,7 +25,8 @@ var switchToOriginalLinks = function() { var a = item.querySelector('a'); var originalUrl = item.querySelector('.favicon').getAttribute('data-originalurl'); var parsedUrl = decodeURIComponent(originalUrl.match(/https?:\/\/getpocket.com\/redirect\?url=(.*)&formCheck=./)[1]); var effectiveUrl = (parsedUrl || originalUrl).replace(/utm_\w+=[^&]+&?/g, ""); a.href = effectiveUrl; item.classList.add('original-link'); }); -
dannvix revised this gist
Jul 12, 2016 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,11 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.7 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.7 fix original link parsing // @history 1.6 disable automatic item synchronization // @history 1.5 hide the live chat button // @history 1.4 rename; update for new Pocket Web @@ -22,7 +23,7 @@ var switchToOriginalLinks = function() { [].forEach.call(allItems, function(item, index) { var a = item.querySelector('a'); var originalUrl = item.querySelector('.favicon').getAttribute('data-originalurl'); var parsedUrl = decodeURIComponent(originalUrl.match(/https?:\/\/getpocket.com\/redirect\?url=(.*)&formCheck=./)[1]); a.href = parsedUrl || originalUrl; item.classList.add('original-link'); }); @@ -48,7 +49,7 @@ var mutationObserver = new MutationObserver(function(mutations) { mutationObserver.observe(target, config); switchToOriginalLinks(); var addCustomizationIndicator = function() { var styles = { background: 'hsla(0, 0%, 0%, 0.67)', bottom: '10px', @@ -92,8 +93,8 @@ var disableItemSynchronization = function() { }; if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addCustomizationIndicator, false); window.addEventListener('load', hideAllShareButtons, false); window.addEventListener('load', hideLiveChatButton, false); // window.addEventListener('load', disableItemSynchronization, false); } -
dannvix revised this gist
Jun 18, 2016 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,11 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.6 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.6 disable automatic item synchronization // @history 1.5 hide the live chat button // @history 1.4 rename; update for new Pocket Web // @history 1.3 efficient patch; hide share buttons @@ -80,8 +81,19 @@ var hideLiveChatButton = function() { } }; var disableItemSynchronization = function() { var delaySecs = 1; setTimeout(function() { // inject script to interact with jQuery var script = document.createElement('script'); script.text = 'jQuery(window).off("focus");'; document.body.appendChild(script); }, delaySecs * 1000/*ms*/); }; if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addOriginalLinkIndicator, false); window.addEventListener('load', hideAllShareButtons, false); window.addEventListener('load', hideLiveChatButton, false); window.addEventListener('load', disableItemSynchronization, false); } -
dannvix revised this gist
Jun 2, 2016 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,11 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.5 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.5 hide the live chat button // @history 1.4 rename; update for new Pocket Web // @history 1.3 efficient patch; hide share buttons // @history 1.2 unbind click event of items @@ -72,7 +73,15 @@ var hideAllShareButtons = function() { document.head.appendChild(style); }; var hideLiveChatButton = function() { var chatBtn = document.querySelector('#livechat-compact-container'); if (chatBtn) { document.body.removeChild(chatBtn); } }; if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addOriginalLinkIndicator, false); window.addEventListener('load', hideAllShareButtons, false); window.addEventListener('load', hideLiveChatButton, false); } -
dannvix renamed this gist
Apr 14, 2015 . 1 changed file with 9 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,14 @@ // ==UserScript== // @name Pocket Web Customized // @description Cusotmizations/Simplifications for Pocket Web // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.4 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.4 rename; update for new Pocket Web // @history 1.3 efficient patch; hide share buttons // @history 1.2 unbind click event of items // @history 1.1 add indicator @@ -27,7 +28,9 @@ var switchToOriginalLinks = function() { // unbind click event handler to prevent batch selection // since we cannot access jQuery here, we use this tricky hack var script = document.createElement('script'); script.text = 'jQuery(".item").off("click");' + 'jQuery(".item_link").off("click");' + 'jQuery(".item_content").off("click");'; document.body.appendChild(script); }; @@ -56,7 +59,7 @@ var addOriginalLinkIndicator = function() { } var indicator = document.createElement('div'); indicator.innerHTML = 'Customizations Applied' for (var attr in styles) { indicator.style[attr] = styles[attr]; } @@ -72,4 +75,4 @@ var hideAllShareButtons = function() { if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addOriginalLinkIndicator, false); window.addEventListener('load', hideAllShareButtons, false); } -
dannvix revised this gist
Dec 20, 2014 . 1 changed file with 24 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,31 +4,34 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.3 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.3 efficient patch; hide share buttons // @history 1.2 unbind click event of items // @history 1.1 add indicator // @history 1.0 initial commmit // ==/UserScript== var switchToOriginalLinks = function() { var allItems = document.querySelectorAll('.item:not(.original-link)'); [].forEach.call(allItems, function(item, index) { var a = item.querySelector('a'); var originalUrl = item.querySelector('.favicon').getAttribute('data-originalurl'); var parsedUrl = decodeURIComponent(originalUrl.match(/https?:\/\/getpocket.com\/redirect\?url=(.*)/)[1]); a.href = parsedUrl || originalUrl; item.classList.add('original-link'); }); // unbind click event handler to prevent batch selection // since we cannot access jQuery here, we use this tricky hack var script = document.createElement('script'); script.text = 'jQuery(".item").off("click");'; document.body.appendChild(script); }; var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var target = document.querySelector('#queue'); var config = { attributes: true, childList: true, characterData: true }; @@ -40,7 +43,6 @@ var mutationObserver = new MutationObserver(function(mutations) { mutationObserver.observe(target, config); switchToOriginalLinks(); var addOriginalLinkIndicator = function() { var styles = { background: 'hsla(0, 0%, 0%, 0.67)', @@ -61,6 +63,13 @@ var addOriginalLinkIndicator = function() { document.body.appendChild(indicator); }; var hideAllShareButtons = function() { var style = document.createElement('style'); style.textContent = 'li.action_share { display: none; }'; document.head.appendChild(style); }; if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addOriginalLinkIndicator, false); window.addEventListener('load', hideAllShareButtons, false); } -
dannvix revised this gist
Dec 13, 2014 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -60,4 +60,7 @@ var addOriginalLinkIndicator = function() { } document.body.appendChild(indicator); }; if (window.location.hostname.toLowerCase().indexOf('getpocket.com') >= 0) { window.addEventListener('load', addOriginalLinkIndicator, false); } -
dannvix revised this gist
Dec 13, 2014 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,11 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.2 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.2 unbind click event of items // @history 1.1 add indicator // @history 1.0 initial commmit // ==/UserScript== @@ -19,10 +20,13 @@ var switchToOriginalLinks = function() { var originalUrl = item.querySelector('.favicon').getAttribute('data-originalurl'); var parsedUrl = decodeURIComponent(originalUrl.match(/https?:\/\/getpocket.com\/redirect\?url=(.*)/)[1]); a.href = parsedUrl || originalUrl; }); // unbind click event handler to prevent batch selection // since we cannot access jQuery here, we use this tricky hack var script = document.createElement('script'); script.text = 'jQuery(".item").off("click");'; document.body.appendChild(script); }; var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; -
dannvix revised this gist
Dec 13, 2014 . 1 changed file with 28 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,11 @@ // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.1 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.1 add indicator // @history 1.0 initial commmit // ==/UserScript== @@ -18,6 +19,9 @@ var switchToOriginalLinks = function() { var originalUrl = item.querySelector('.favicon').getAttribute('data-originalurl'); var parsedUrl = decodeURIComponent(originalUrl.match(/https?:\/\/getpocket.com\/redirect\?url=(.*)/)[1]); a.href = parsedUrl || originalUrl; // unbind click event handler to prevent batch selection item.off("click"); }); }; @@ -30,4 +34,26 @@ var mutationObserver = new MutationObserver(function(mutations) { }); mutationObserver.observe(target, config); switchToOriginalLinks(); var addOriginalLinkIndicator = function() { var styles = { background: 'hsla(0, 0%, 0%, 0.67)', bottom: '10px', color: 'white', fontSize: '8pt', padding: '5px 7px', position: 'fixed', right: '10px', zIndex: '9999', } var indicator = document.createElement('div'); indicator.innerHTML = 'Original Links Enabled' for (var attr in styles) { indicator.style[attr] = styles[attr]; } document.body.appendChild(indicator); }; window.addEventListener('load', addOriginalLinkIndicator, false); -
dannvix created this gist
Dec 11, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ // ==UserScript== // @name Pocket Original Link // @description Use original link by default // @namespace http://getpocket.com // @author Shao-Chung Chen // @license MIT (http://opensource.org/licenses/MIT) // @version 1.0 // @include http://getpocket.com/* // @include https://getpocket.com/* // // @history 1.0 initial commmit // ==/UserScript== var switchToOriginalLinks = function() { var allItems = document.querySelectorAll('.item'); [].forEach.call(allItems, function(item, index) { var a = item.querySelector('a'); var originalUrl = item.querySelector('.favicon').getAttribute('data-originalurl'); var parsedUrl = decodeURIComponent(originalUrl.match(/https?:\/\/getpocket.com\/redirect\?url=(.*)/)[1]); a.href = parsedUrl || originalUrl; }); }; var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var target = document.querySelector('#queue'); var config = { attributes: true, childList: true, characterData: true }; var mutationObserver = new MutationObserver(function(mutations) { switchToOriginalLinks(); }); mutationObserver.observe(target, config); switchToOriginalLinks();